Skip to content

tolnaiz/keyboard-switcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Keyboard Switch

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.

Features

  • 🔄 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

Requirements

  • macOS 12.0 (Monterey) or later
  • Xcode 13+ (for building)

Building

  1. Clone the repository:

    git clone https://github.com/tolnaiz/keyboard-switch.git
    cd keyboard-switch
  2. Open in Xcode:

    open "Keyboard Switch.xcodeproj"
  3. Build and run with ⌘R, or archive for release with Product → Archive.

Alternatively, build from the command line:

xcodebuild -project "Keyboard Switch.xcodeproj" -scheme "Keyboard Switch" -configuration Release

Running Unsigned Builds

If you download a pre-built release or build without code signing, macOS Gatekeeper will block the app. To allow it:

  1. Try to open the app normally (it will be blocked)
  2. Go to System Settings → Privacy & Security
  3. Scroll down to find the message about "Keyboard Switch" being blocked
  4. Click Open Anyway

Alternatively, remove the quarantine attribute via Terminal:

xattr -dr com.apple.quarantine "/Applications/Keyboard Switch.app"

Configuration

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.

Finding Bundle IDs and Layout IDs

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.

License

MIT

About

A macOS utility that automatically switches keyboard input sources based on the active application.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors