Skip to content

Instantly share code, notes, and snippets.

@sam159247
Last active April 30, 2022 03:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sam159247/590e96cd94825e798c64ea3d9ecadd86 to your computer and use it in GitHub Desktop.
Save sam159247/590e96cd94825e798c64ea3d9ecadd86 to your computer and use it in GitHub Desktop.
[Karabiner-Elements] One key to change input source
{
"title": "Language toggler",
"rules": [
{
"description": "left_shift=English, left_option=Shuangpin, right_command=Japanese, ecs=Reset_ime",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "left_shift",
"modifiers": {
"optional": ["any"]
}
},
"parameters": {
"basic.to_if_held_down_threshold_milliseconds": 100
},
"to": [
{
"key_code": "left_shift",
"lazy": true
}
],
"to_if_held_down": [
{
"key_code": "left_shift"
}
],
"to_if_alone": [
{
"select_input_source": {
"input_source_id": "com.apple.keylayout.ABC"
}
}
]
},
{
"type": "basic",
"from": {
"key_code": "left_option",
"modifiers": {
"optional": ["any"]
}
},
"parameters": {
"basic.to_if_held_down_threshold_milliseconds": 100
},
"to": [
{
"key_code": "left_option",
"lazy": true
}
],
"to_if_held_down": [
{
"key_code": "left_option"
}
],
"to_if_alone": [
{
"select_input_source": {
"input_mode_id": "com.apple.inputmethod.TCIM.Shuangpin",
"input_source_id": "com.apple.inputmethod.TCIM.Shuangpin",
"language": "zh-Hant"
}
}
]
},
{
"type": "basic",
"from": {
"key_code": "right_command",
"modifiers": {
"optional": ["any"]
}
},
"parameters": {
"basic.to_if_held_down_threshold_milliseconds": 100
},
"to": [
{
"key_code": "right_command",
"lazy": true
}
],
"to_if_held_down": [
{
"key_code": "right_command"
}
],
"to_if_alone": [
{
"select_input_source": {
"input_mode_id": "com.apple.inputmethod.Japanese",
"input_source_id": "com.apple.inputmethod.Kotoeri.RomajiTyping.Japanese",
"language": "ja"
}
}
]
},
{
"type": "basic",
"from": {
"key_code": "escape",
"modifiers": {
"optional": ["any"]
}
},
"parameters": {
"basic.to_if_held_down_threshold_milliseconds": 3000
},
"to": [
{
"key_code": "escape",
"lazy": true
}
],
"to_if_held_down": [
{
"shell_command": "pkill -u $(whoami) -f /usr/sbin/distnoted && pkill -u $(whoami) -if input"
}
]
}
]
}
]
}
@sam159247
Copy link
Author

sam159247 commented Jul 26, 2020

Tips

  • Use Karabiner's Event Viewer to get Input Source ID.
  • Move this setting to ~/.config/karabiner/assets/complex_modifications

Reference

https://gist.github.com/noma4i/91765f432f777c690aa3bddae37cfe3e
https://ke-complex-modifications.pqrs.org/#international
https://karabiner-elements.pqrs.org/docs/json/location/

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