A lightweight macOS utility that automatically switches keyboard input sources based on the active application. Perfect for developers who prefer a programmer-friendly layout (like US-QWERTZ) in code editors and terminals, but their native language layout elsewhere.
- 🔄 Automatic keyboard layout switching when apps gain focus
- ⚙️ JSON-based configuration with hot-reload (no restart needed)
- 🪶 Runs completely silently (no menubar, no dock icon)
- 🖥️ Native macOS app using Carbon Text Input Source APIs
- macOS 12.0 (Monterey) or later
- Xcode 13+ (for building)
-
Clone the repository:
git clone https://github.com/tolnaiz/keyboard-switch.git cd keyboard-switch -
Open in Xcode:
open "Keyboard Switch.xcodeproj" -
Build and run with
⌘R, or archive for release withProduct → Archive.
Alternatively, build from the command line:
xcodebuild -project "Keyboard Switch.xcodeproj" -scheme "Keyboard Switch" -configuration ReleaseIf you download a pre-built release or build without code signing, macOS Gatekeeper will block the app. To allow it:
- Try to open the app normally (it will be blocked)
- Go to System Settings → Privacy & Security
- Scroll down to find the message about "Keyboard Switch" being blocked
- Click Open Anyway
Alternatively, remove the quarantine attribute via Terminal:
xattr -dr com.apple.quarantine "/Applications/Keyboard Switch.app"On first launch, the app creates a config file at:
~/.config/keyboard-switch/config.json
Example configuration:
{
"defaultLayout": "com.apple.keylayout.US",
"appLayouts": {
"com.apple.dt.Xcode": "org.unknown.keylayout.USqwertz",
"com.microsoft.VSCode": "org.unknown.keylayout.USqwertz",
"com.apple.Terminal": "org.unknown.keylayout.USqwertz"
}
}- defaultLayout: Keyboard layout used for apps not in
appLayouts - appLayouts: Map of app bundle IDs → keyboard layout IDs
Changes are applied immediately—no restart required.
To find an app's bundle ID:
osascript -e 'id of app "App Name"'To list available keyboard layouts, check System Preferences → Keyboard → Input Sources or use the Console.app to view logs when switching apps.
MIT