ke-auto-profile-switcher
What's this?
This CLI automatically switches Karabiner-Elements profiles based on USB keyboard connection status. When an external USB keyboard is connected, it switches to your designated profile for external keyboards. When disconnected, it switches back to your default profile.
Features
- Automatic Profile Switching: Seamlessly switches between Karabiner profiles based on USB keyboard connection
- Multiple Configuration Methods: Support for configuration files, command-line arguments, or interactive setup
- Interactive Setup: First-time users are guided through an easy setup process
- USB Device Detection: Lists available USB devices to help identify your keyboard's product ID
Install
Quick Start
Method 1: Interactive Setup (Recommended for first-time users)
# Simply run watch command - you'll be guided through setup if no config exists
Method 2: Using Command-Line Arguments
# Check your USB keyboard's product ID first
# Start watching with your keyboard's details
Method 3: Configuration File
Create ~/.config/ke_auto_profile_switcher/config.yml:
keyboard_id: 1234
product_profile: "External Keyboard"
default_profile: "Default"
Then simply run:
Usage
Commands
kaps check
Lists all connected USB devices with their product IDs. Use this to identify your external keyboard's product ID.
kaps watch
Starts monitoring USB device connections and automatically switches Karabiner profiles.
# Interactive mode (will prompt for configuration if needed)
# With command-line arguments
# With all options
Options
--keyboard-id(-k): USB product ID of your external keyboard--product-profile(-p): Karabiner profile name to use when external keyboard is connected--default-profile(-d): Karabiner profile name to use when external keyboard is disconnected (defaults to "Default")
Configuration Priority
The application uses configuration in the following priority order:
- Configuration file (if exists):
~/.config/ke_auto_profile_switcher/config.yml - Command-line arguments (if keyboard-id and product-profile are provided)
- Interactive setup (if neither config file nor complete arguments are provided)
Example Workflow
-
Find your keyboard's product ID:
-
Start monitoring (interactive setup):
-
Connect/disconnect your external keyboard and watch the automatic profile switching!
Requirements
- macOS with Karabiner-Elements installed
- The application assumes Karabiner-Elements is installed in the default location
LICENSE
MIT License
Copyright (c) 2022 HIRAKI Satoru
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.