Skip to content

Instantly share code, notes, and snippets.

@val314159
Last active August 22, 2020 13:21
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 val314159/97f51b24569cc559023195512efc5e83 to your computer and use it in GitHub Desktop.
Save val314159/97f51b24569cc559023195512efc5e83 to your computer and use it in GitHub Desktop.
karabiner json, stick this in ~/.config/karabiner/assets/complex_modifications/keys.json
#!/usr/bin/env python3
import os, sys
from sys import argv
from os import system
prog = argv.pop(0)
frst = argv.pop(0)
last = argv.pop()
system('cat '+frst)
for fn in argv:
system('cat '+fn)
system('echo ","')
pass
system('cat '+last)
system('echo "]}"')
{
"title": "my stuff",
"rules": [
{
"description": "left shift, misc",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "m",
"modifiers": {
"mandatory": [
"left_shift",
"right_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "slash",
"modifiers": [
"right_shift"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "m",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "slash"
}
]
},
{
"type": "basic",
"from": {
"key_code": "n",
"modifiers": {
"mandatory": [
"left_shift",
"right_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "backslash",
"modifiers": [
"right_shift"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "n",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "backslash"
}
]
},
{
"type": "basic",
"from": {
"key_code": "z",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "hyphen",
"modifiers": [
"right_shift"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "x",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "hyphen"
}
]
},
{
"type": "basic",
"from": {
"key_code": "c",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "equal_sign"
}
]
},
{
"type": "basic",
"from": {
"key_code": "v",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "equal_sign",
"modifiers": [
"right_shift"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "b",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "quote"
}
]
},
{
"type": "basic",
"from": {
"key_code": "slash",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "period"
}
]
},
{
"type": "basic",
"from": {
"key_code": "backslash",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "comma"
}
]
}
]
}
{
"description": "Change left control (capslock->ctl/tab)",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "left_control",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "left_control"
}
],
"to_if_alone": [
{
"key_code": "escape"
}
]
}
]
}
{
"description": "caps_lock := left control / escape",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "caps_lock",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "left_control"
}
],
"to_if_alone": [
{
"key_code": "tab"
}
]
}
]
}
{
"description": "Change left control (capslock->ctl/tab)",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "caps_lock",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "left_control"
}
],
"to_if_alone": [
{
"key_code": "escape"
}
]
}
]
}
{
"description": "Change command-x to meta-x",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "w",
"modifiers": {
"mandatory": [
"left_command"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "x",
"modifiers": [
"right_command"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "x",
"modifiers": {
"mandatory": [
"left_command"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "x",
"modifiers": [
"left_option"
]
}
]
}
]
}
{
"description": "crsr1",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "p",
"modifiers": {
"mandatory": [
"right_command",
"right_option"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "p",
"modifiers": [
"left_command"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "l",
"modifiers": {
"mandatory": [
"right_command",
"right_option"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "l",
"modifiers": [
"left_command"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "semicolon",
"modifiers": {
"mandatory": [
"right_command",
"right_option"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "semicolon",
"modifiers": [
"left_command"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "quote",
"modifiers": {
"mandatory": [
"right_command",
"right_option"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "quote",
"modifiers": [
"left_command"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "p",
"modifiers": {
"mandatory": [
"right_command"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "up_arrow"
}
]
},
{
"type": "basic",
"from": {
"key_code": "l",
"modifiers": {
"mandatory": [
"right_command"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "left_arrow"
}
]
},
{
"type": "basic",
"from": {
"key_code": "semicolon",
"modifiers": {
"mandatory": [
"right_command"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "down_arrow"
}
]
},
{
"type": "basic",
"from": {
"key_code": "quote",
"modifiers": {
"mandatory": [
"right_command"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "right_arrow"
}
]
}
]
}
{
"description": "Cursor keys LtCtl+pl;'",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "l",
"modifiers": {
"mandatory": [
"left_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "left_arrow"
}
]
},
{
"type": "basic",
"from": {
"key_code": "quote",
"modifiers": {
"mandatory": [
"left_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "right_arrow"
}
]
},
{
"type": "basic",
"from": {
"key_code": "p",
"modifiers": {
"mandatory": [
"left_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "up_arrow"
}
]
},
{
"type": "basic",
"from": {
"key_code": "semicolon",
"modifiers": {
"mandatory": [
"left_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "down_arrow"
}
]
}
]
}
{
"description": "augment tab",
"manipulators": [
{
"from": {
"key_code": "4",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"hold_down_milliseconds": 0,
"key_code": "caps_lock"
},
{
"key_code": "vk_none"
}
],
"type": "basic"
},
{
"type": "basic",
"from": {
"key_code": "i",
"modifiers": {
"mandatory": [
"caps_lock"
],
"optional": [
]
}
},
"to": [
{
"key_code": "up_arrow",
"modifiers": [
"caps_lock"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "j",
"modifiers": {
"mandatory": [
"caps_lock"
],
"optional": [
]
}
},
"to": [
{
"key_code": "left_arrow",
"modifiers": [
"caps_lock"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "k",
"modifiers": {
"mandatory": [
"caps_lock"
],
"optional": [
]
}
},
"to": [
{
"key_code": "down_arrow",
"modifiers": [
"caps_lock"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "l",
"modifiers": {
"mandatory": [
"caps_lock"
],
"optional": [
]
}
},
"to": [
{
"key_code": "right_arrow",
"modifiers": [
"caps_lock"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "semicolon",
"modifiers": {
"mandatory": [
"caps_lock"
],
"optional": [
]
}
},
"to": [
{
"key_code": "caps_lock",
"modifiers": [
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "left_control",
"modifiers": {
"mandatory": [
],
"optional": [
"any"
]
}
},
"to_if_alone": [
{
"key_code": "tab"
}
],
"to": [
{
"key_code": "left_control"
}
]
},
{
"type": "basic",
"from": {
"key_code": "right_command",
"modifiers": {
"mandatory": [
],
"optional": [
"caps_lock"
]
}
},
"to": [
{
"key_code": "right_command",
"modifiers": [
"caps_lock"
]
}
],
"to_if_alone": [
{
"halt": true,
"key_code": "right_command",
"modifiers": [
]
}
],
"to_after_key_up": [
{
"key_code": "right_command",
"modifiers": [
"caps_lock"
]
}
],
"parameters": {
"basic.to_delayed_action_delay_milliseconds": 500
}
},
{
"type": "basic",
"from": {
"key_code": "left_command",
"modifiers": {
"mandatory": [
"caps_lock"
],
"optional": [
"right_command"
]
}
},
"to": [
{
"key_code": "right_command",
"modifiers": [
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "right_shift",
"modifiers": {
"mandatory": [
"left_option"
],
"optional": [
]
}
},
"to": [
{
"repeat": false,
"key_code": "escape",
"modifiers": [
]
},
{
"key_code": "right_shift"
}
]
},
{
"type": "basic",
"from": {
"key_code": "left_option",
"modifiers": {
"mandatory": [
],
"optional": [
"any"
]
}
},
"to_if_alone": [
{
"key_code": "escape",
"modifiers": [
]
}
],
"to": [
{
"key_code": "left_option"
}
]
}
]
}
{
"description": "Change pgup/pgdn (tab->meta/esc)",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "comma",
"modifiers": {
"mandatory": [
"right_shift",
"left_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "escape"
},
{
"key_code": "comma",
"modifiers": [
"right_shift"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "period",
"modifiers": {
"mandatory": [
"right_shift",
"left_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "escape"
},
{
"key_code": "period",
"modifiers": [
"right_shift"
]
}
]
}
]
}
{
"description": "left option",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "left_option",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "left_option"
}
],
"to_if_alone": [
{
"key_code": "escape"
}
]
}
]
}
qall: clean tmp2.out
cp tmp2.out ../tmp2.out
tmp2.out:
python -um%filter %prelude.json grail.js | tee $@
call: clean all
all: tmp.out
cp tmp.out ..
tmp.out: *.json
python -um%filter *.json | tee $@
clean:
rm -fr *.out *~ *.pyc __pycache__
{
"description": "left shift (mostly number row)",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "q",
"modifiers": {
"mandatory": [
"right_shift",
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "r"
}
]
},
{
"type": "basic",
"from": {
"key_code": "q",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "g",
"modifiers": [
"right_shift"
]
}
]
}
]
}
{
"description": "numbers",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "o",
"modifiers": {
"mandatory": [
"left_control"
],
"optional": [
]
}
},
"to": [
{
"key_code": "open_bracket"
}
]
},
{
"type": "basic",
"from": {
"key_code": "p",
"modifiers": {
"mandatory": [
"left_control"
],
"optional": [
]
}
},
"to": [
{
"key_code": "close_bracket"
}
]
},
{
"type": "basic",
"from": {
"key_code": "u",
"modifiers": {
"mandatory": [
"left_shift",
"right_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "open_bracket",
"modifiers": [
"right_shift"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "i",
"modifiers": {
"mandatory": [
"left_shift",
"right_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "close_bracket",
"modifiers": [
"right_shift"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "q",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "1",
"modifiers": [
"left_shift"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "a",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "1"
}
]
},
{
"type": "basic",
"from": {
"key_code": "w",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "2",
"modifiers": [
"left_shift"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "s",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "2"
}
]
},
{
"type": "basic",
"from": {
"key_code": "e",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "3",
"modifiers": [
"left_shift"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "d",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "3"
}
]
},
{
"type": "basic",
"from": {
"key_code": "r",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "4",
"modifiers": [
"left_shift"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "f",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "4"
}
]
},
{
"type": "basic",
"from": {
"key_code": "t",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "5",
"modifiers": [
"left_shift"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "g",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "5"
}
]
},
{
"type": "basic",
"from": {
"key_code": "y",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "6",
"modifiers": [
"left_shift"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "h",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "6"
}
]
},
{
"type": "basic",
"from": {
"key_code": "u",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "7",
"modifiers": [
"left_shift"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "j",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "7"
}
]
},
{
"type": "basic",
"from": {
"key_code": "i",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "8",
"modifiers": [
"left_shift"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "k",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "8"
}
]
},
{
"type": "basic",
"from": {
"key_code": "o",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "open_bracket"
}
]
},
{
"type": "basic",
"from": {
"key_code": "l",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "9"
}
]
},
{
"type": "basic",
"from": {
"key_code": "p",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "close_bracket"
}
]
},
{
"type": "basic",
"from": {
"key_code": "semicolon",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "0"
}
]
}
]
}
{
"description": "augment tab",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "escape",
"modifiers": {
"mandatory": [
],
"optional": [
"any"
]
}
},
"to_if_alone": [
{
"key_code": "tab"
}
],
"to": [
{
"key_code": "left_control"
}
]
},
{
"type": "basic",
"from": {
"key_code": "right_command",
"modifiers": {
"mandatory": [
],
"optional": [
"caps_lock", "right_command"
]
}
},
"to": [
{
"key_code": "right_command",
"modifiers": [
"caps_lock"
]
}
],
"to_delayed_action": {
"to_if_invoked": [
],
"to_if_canceled": [
{
"halt": true,
"key_code": "right_command",
"modifiers": [
"caps_lock"
]
}
]
},
"parameters": {
"basic.to_delayed_action_delay_milliseconds": 250
},
"to_after_key_up": [
]
},
{
"type": "basic",
"from": {
"key_code": "right_shift",
"modifiers": {
"mandatory": [
"left_option"
],
"optional": [
]
}
},
"to": [
{
"repeat": false,
"key_code": "escape",
"modifiers": [
]
},
{
"key_code": "right_shift"
}
]
},
{
"type": "basic",
"from": {
"key_code": "left_option",
"modifiers": {
"mandatory": [
],
"optional": [
"any"
]
}
},
"to_if_alone": [
{
"key_code": "escape",
"modifiers": [
]
}
],
"to": [
{
"key_code": "left_option"
}
]
}
]
}
{
"description": "shorten",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "quote",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "return_or_enter"
}
]
},
{
"type": "basic",
"from": {
"key_code": "slash",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "right_shift"
}
]
},
{
"type": "basic",
"from": {
"key_code": "backslash",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "delete_or_backspace"
}
]
}
]
}
{
"description": "spacebar",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "spacebar",
"modifiers": {
"mandatory": [
"left_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "hyphen",
"modifiers": [
"right_shift"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "spacebar",
"modifiers": {
"mandatory": [
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "spacebar",
"modifiers": [
"left_control"
]
}
]
}
]
}
{
"description": "augment tab",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "tab",
"modifiers": {
"mandatory": [
"right_shift"
],
"optional": [
]
}
},
"to": [
{
"key_code": "grave_accent_and_tilde",
"modifiers": [
"right_shift"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "tab",
"modifiers": {
"mandatory": [
"right_command"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "grave_accent_and_tilde"
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment