Skip to content

Instantly share code, notes, and snippets.

@dreikanter
Created August 27, 2025 18:03
Show Gist options
  • Save dreikanter/74a97b972035f8114ad68a52bce17e13 to your computer and use it in GitHub Desktop.
Save dreikanter/74a97b972035f8114ad68a52bce17e13 to your computer and use it in GitHub Desktop.
Karabinier-Elements idempotent hotkeys configuration for switching between two keyboard layouts
{
"description": "Use idempotent hotkeys to switch between two keyboard layouts",
"manipulators": [
{
"from": {
"key_code": "1",
"modifiers": {
"mandatory": ["left_command", "left_option"],
"optional": ["any"]
}
},
"to": [
{
"key_code": "1",
"modifiers": ["left_command", "left_option"]
}
],
"to_if_alone": [{ "select_input_source": { "input_source_id": "english" } }],
"type": "basic"
},
{
"from": {
"key_code": "2",
"modifiers": {
"mandatory": ["left_command", "left_option"],
"optional": ["any"]
}
},
"to": [
{
"key_code": "2",
"modifiers": ["left_command", "left_option"]
}
],
"to_if_alone": [{ "select_input_source": { "input_source_id": "russian" } }],
"type": "basic"
}
]
}
@dreikanter
Copy link
Author

How to install:

  • Karabiner-Elements Settings → Complex Modifications → Add your own rule
  • See also

How to customize keyboard layouts:

  • Figure out input_source_id values for your installed keyboard layouts using im-select tool.
  • Replace english and russian in the configuration above with case-sensitive substring (or a regular expression) for each keyboard layout id. For instance, just use "english" for org.sil.ukelele.keyboardlayout.english-custom-layout.

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment