Skip to content

Instantly share code, notes, and snippets.

@xerial
Last active June 9, 2023 03:37
Show Gist options
  • Save xerial/fef997c8e372b0a618c22d67edcb16c1 to your computer and use it in GitHub Desktop.
Save xerial/fef997c8e372b0a618c22d67edcb16c1 to your computer and use it in GitHub Desktop.
Karabiner Cursor Mode Setting. Put this file in ~/.config/karabiner/assets/complex_modifications/
{
"title": "Cursor-mode layout for saving your little fingers",
"rules": [
{
"description": "Cursor-mode: Enter the cursor mode with left command click. i/j/k/l to arrows. Exit when ctrl/esc/enter/backspace or command+(any) is pressed.",
"manipulators": [
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "left_command",
"modifiers": {
"optional": [
"any"
]
}
},
"parameters": {
"basic.to_if_held_down_threshold_milliseconds": 100
},
"to": [
{
"set_variable": {
"name": "cursor_layout",
"value": 0
}
},
{
"key_code": "left_command",
"lazy": true
}
],
"to_if_alone": [
{
"set_variable": {
"name": "cursor_layout",
"value": 1
}
}
],
"to_if_held_down": [
{
"set_variable": {
"name": "cursor_layout",
"value": 0
}
},
{
"key_code": "left_command",
"lazy": true
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 0
}
],
"from": {
"key_code": "left_command"
},
"parameters": {
"basic.to_if_held_down_threshold_milliseconds": 100
},
"to": [
{
"key_code": "left_command",
"lazy": true
}
],
"to_if_alone": [
{
"set_variable": {
"name": "cursor_layout",
"value": 1
}
}
],
"to_if_held_down": [
{
"key_code": "left_command",
"lazy": true
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "left_control",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"set_variable": {
"name": "cursor_layout",
"value": 0
}
},
{
"key_code": "left_control",
"lazy": true
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "escape"
},
"to": [
{
"set_variable": {
"name": "cursor_layout",
"value": 0
}
},
{
"key_code": "escape"
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "delete_or_backspace"
},
"to": [
{
"set_variable": {
"name": "cursor_layout",
"value": 0
}
},
{
"key_code": "delete_or_backspace"
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "tab"
},
"to": [
{
"set_variable": {
"name": "cursor_layout",
"value": 0
}
},
{
"key_code": "tab"
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "return_or_enter"
},
"to": [
{
"set_variable": {
"name": "cursor_layout",
"value": 0
}
},
{
"key_code": "return_or_enter"
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "i",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "up_arrow"
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "j",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "left_arrow"
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "k",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "down_arrow"
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "l",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "right_arrow"
}
],
"type": "basic"
}
]
},
{
"description": "Cursor-mode: q/v to ctrl+up/down (paragraph-level move)",
"manipulators": [
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "q",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "up_arrow",
"modifiers": [
"left_control"
]
},
{
"set_variable": {
"name": "cursor_layout",
"value": 1
}
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "v",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "down_arrow",
"modifiers": [
"left_control"
]
},
{
"set_variable": {
"name": "cursor_layout",
"value": 1
}
}
],
"type": "basic"
}
]
},
{
"description": "Cursor-mode: w/f to option+left/right (word-level move)",
"manipulators": [
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "w",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "left_arrow",
"modifiers": [
"left_option"
]
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "f",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "right_arrow",
"modifiers": [
"left_option"
]
}
],
"type": "basic"
}
]
},
{
"description": "Cursor-mode: a/e to home/end",
"manipulators": [
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "a",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "home"
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "e",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "end"
}
],
"type": "basic"
}
]
},
{
"description": "Cursor-mode: [, ] to ⌘+[, ] (browser back/forward)",
"manipulators": [
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "open_bracket",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "open_bracket",
"modifiers": [
"left_command"
]
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "close_bracket",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "close_bracket",
"modifiers": [
"left_command"
]
}
],
"type": "basic"
}
]
},
{
"description": "Cursor-mode: Volume Up (,) and Volume Down (period)",
"manipulators": [
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "comma"
},
"to": [
{
"consumer_key_code": "volume_decrement"
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "period"
},
"to": [
{
"consumer_key_code": "volume_increment"
}
],
"type": "basic"
}
]
},
{
"description": "Cursor-mode: ;/' to C-S-Tab/C-Tab (switch tab)",
"manipulators": [
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "semicolon"
},
"to": [
{
"key_code": "tab",
"modifiers": [
"left_shift",
"left_control"
]
},
{
"set_variable": {
"name": "cursor_layout",
"value": 1
}
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "quote"
},
"to": [
{
"key_code": "tab",
"modifiers": [
"left_control"
]
},
{
"set_variable": {
"name": "cursor_layout",
"value": 1
}
}
],
"type": "basic"
}
]
},
{
"description": "Cursor-mode: U to ⌘+Z (Undo), R to ⌘-S-Z (Redo), slash(/) to ⌘ + F (search)",
"manipulators": [
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "slash",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"set_variable": {
"name": "cursor_layout",
"value": 0
}
},
{
"key_code": "f",
"modifiers": [
"left_command"
]
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "u",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "z",
"modifiers": [
"left_command"
]
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "r",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "z",
"modifiers": [
"left_shift",
"left_command"
]
}
],
"type": "basic"
}
]
},
{
"description": "Cursor-mode: Copy (C), Paste/Yank (Y), Cut (X), and Undo (Z)",
"manipulators": [
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "c",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "c",
"modifiers": [
"left_command"
]
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "y",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "v",
"modifiers": [
"left_command"
]
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "x",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "x",
"modifiers": [
"left_command"
]
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "z",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "z",
"modifiers": [
"left_command"
]
}
],
"type": "basic"
}
]
},
{
"description": "Cursor-mode: p/n to up/down",
"manipulators": [
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "p",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "up_arrow"
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "n",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "down_arrow"
}
],
"type": "basic"
}
]
},
{
"description": "Cursor-mode: o/h to page_up/page_down",
"manipulators": [
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "o",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "page_up"
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "h",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "page_down"
}
],
"type": "basic"
}
]
},
{
"description": "Cursor-mode: s to backspace, d delete_forward",
"manipulators": [
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "s"
},
"to": [
{
"key_code": "delete_or_backspace"
},
{
"set_variable": {
"name": "cursor_layout",
"value": 1
}
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "d"
},
"to": [
{
"key_code": "delete_forward"
},
{
"set_variable": {
"name": "cursor_layout",
"value": 1
}
}
],
"type": "basic"
}
]
},
{
"description": "Cursor-mode: t/g/b/m to option+t/g/b/m and exit cursor-mode",
"manipulators": [
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "t"
},
"to": [
{
"set_variable": {
"name": "cursor_layout",
"value": 0
}
},
{
"key_code": "t",
"modifiers": [
"left_option"
]
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "g"
},
"to": [
{
"set_variable": {
"name": "cursor_layout",
"value": 0
}
},
{
"key_code": "g",
"modifiers": [
"left_option"
]
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "b"
},
"to": [
{
"set_variable": {
"name": "cursor_layout",
"value": 0
}
},
{
"key_code": "b",
"modifiers": [
"left_option"
]
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cursor_layout",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "m"
},
"to": [
{
"set_variable": {
"name": "cursor_layout",
"value": 0
}
},
{
"key_code": "m",
"modifiers": [
"left_option"
]
}
],
"type": "basic"
}
]
},
{
"description": "Cursor-mode: Right command click to Japanes/Eisuu toggle and exit the cursor mode",
"manipulators": [
{
"conditions": [
{
"input_sources": [
{
"language": "ja"
}
],
"type": "input_source_if"
}
],
"from": {
"key_code": "right_command",
"modifiers": {
"optional": [
"any"
]
}
},
"parameters": {
"basic.to_if_held_down_threshold_milliseconds": 100
},
"to": [
{
"set_variable": {
"name": "cursor_layout",
"value": 0
}
},
{
"key_code": "right_command",
"lazy": true
}
],
"to_if_alone": [
{
"set_variable": {
"name": "cursor_layout",
"value": 0
}
},
{
"key_code": "japanese_eisuu"
}
],
"to_if_held_down": [
{
"set_variable": {
"name": "cursor_layout",
"value": 0
}
},
{
"key_code": "right_command"
}
],
"type": "basic"
},
{
"conditions": [
{
"input_sources": [
{
"language": "en"
}
],
"type": "input_source_if"
}
],
"from": {
"key_code": "right_command",
"modifiers": {
"optional": [
"any"
]
}
},
"parameters": {
"basic.to_if_held_down_threshold_milliseconds": 100
},
"to": [
{
"set_variable": {
"name": "cursor_layout",
"value": 0
}
},
{
"key_code": "right_command",
"lazy": true
}
],
"to_if_alone": [
{
"set_variable": {
"name": "cursor_layout",
"value": 0
}
},
{
"key_code": "japanese_kana"
}
],
"to_if_held_down": [
{
"set_variable": {
"name": "cursor_layout",
"value": 0
}
},
{
"key_code": "right_command"
}
],
"type": "basic"
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment