Skip to content

Instantly share code, notes, and snippets.

@tolgabalci
Created May 13, 2026 05:00
Show Gist options
  • Select an option

  • Save tolgabalci/eac9bec3886c9088d49a65f6f5ac3b12 to your computer and use it in GitHub Desktop.

Select an option

Save tolgabalci/eac9bec3886c9088d49a65f6f5ac3b12 to your computer and use it in GitHub Desktop.
Karabiner-Elements config: Caps Lock as Hyper Key with App and Config sublayers
{
"_notes": [
"=== Hyper Key + Sublayer Design ===",
"",
"Caps Lock is remapped to a Hyper Key (left_shift + cmd + ctrl + opt).",
"Tapped alone, Caps Lock still types Caps Lock (200ms hold).",
"",
"Sublayers work by Hyper + <leader> setting a variable while held,",
"then a second key (no modifiers needed) is checked against that variable.",
"Release the leader to exit the sublayer.",
"",
"--- Hyper + A → App sublayer (variable: hyper_sublayer_app) ---",
" F → Finder",
" G → Google Chrome",
" V → Visual Studio Code",
" O → Codex",
" N → Google Docs / Notes (Chrome PWA, bundle id com.google.Chrome.app.mpnpojknpmmopombnjdcgaaiekajbnjb)",
" Note: D was the natural choice but Hyper+D never reached the rule —",
" another shortcut on the system (likely Logitech Options or a macOS",
" lookup binding) swallowed the keypress, so we use N (notes) instead.",
"",
"--- Hyper + C → Config sublayer (variable: hyper_sublayer_config) ---",
" K → code ~/.config/karabiner/karabiner.json",
" . → code ~/code/general",
"",
"Note: shell_command runs without the user shell PATH, so use",
"absolute paths (e.g. /usr/local/bin/code).",
"",
"Note: editing this profile via the Karabiner-Elements GUI may strip",
"this _notes key. Keep a backup if that happens."
],
"profiles": [
{
"complex_modifications": {
"rules": [
{
"description": "Caps Lock → Hyper Key (^⌥⇧⌘) (Caps Lock if alone)",
"manipulators": [
{
"from": {
"key_code": "caps_lock",
"modifiers": { "optional": ["any"] }
},
"to": [
{
"key_code": "left_shift",
"lazy": true,
"modifiers": ["left_command", "left_control", "left_option"]
}
],
"to_if_alone": [
{
"hold_down_milliseconds": 200,
"key_code": "caps_lock"
}
],
"type": "basic"
}
]
},
{
"description": "Hyper + A → App sublayer",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "a",
"modifiers": {
"mandatory": ["left_command", "left_control", "left_option", "left_shift"],
"optional": ["caps_lock"]
}
},
"to": [
{
"set_variable": {
"name": "hyper_sublayer_app",
"value": 1
}
}
],
"to_after_key_up": [
{
"set_variable": {
"name": "hyper_sublayer_app",
"value": 0
}
}
]
}
]
},
{
"description": "App sublayer: F→Finder, G→Chrome, V→VSCode, O→Codex, N→Google Docs (notes)",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "f",
"modifiers": { "optional": ["any"] }
},
"to": [
{
"shell_command": "open -a 'Finder'"
}
],
"conditions": [
{
"type": "variable_if",
"name": "hyper_sublayer_app",
"value": 1
}
]
},
{
"type": "basic",
"from": {
"key_code": "g",
"modifiers": { "optional": ["any"] }
},
"to": [
{
"shell_command": "open -a 'Google Chrome'"
}
],
"conditions": [
{
"type": "variable_if",
"name": "hyper_sublayer_app",
"value": 1
}
]
},
{
"type": "basic",
"from": {
"key_code": "v",
"modifiers": { "optional": ["any"] }
},
"to": [
{
"shell_command": "open -a 'Visual Studio Code'"
}
],
"conditions": [
{
"type": "variable_if",
"name": "hyper_sublayer_app",
"value": 1
}
]
},
{
"type": "basic",
"from": {
"key_code": "o",
"modifiers": { "optional": ["any"] }
},
"to": [
{
"shell_command": "open -a 'Codex'"
}
],
"conditions": [
{
"type": "variable_if",
"name": "hyper_sublayer_app",
"value": 1
}
]
},
{
"type": "basic",
"from": {
"key_code": "n",
"modifiers": { "optional": ["any"] }
},
"to": [
{
"shell_command": "open -b com.google.Chrome.app.mpnpojknpmmopombnjdcgaaiekajbnjb"
}
],
"conditions": [
{
"type": "variable_if",
"name": "hyper_sublayer_app",
"value": 1
}
]
}
]
},
{
"description": "Hyper + C → Config sublayer",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "c",
"modifiers": {
"mandatory": ["left_command", "left_control", "left_option", "left_shift"],
"optional": ["caps_lock"]
}
},
"to": [
{
"set_variable": {
"name": "hyper_sublayer_config",
"value": 1
}
}
],
"to_after_key_up": [
{
"set_variable": {
"name": "hyper_sublayer_config",
"value": 0
}
}
]
}
]
},
{
"description": "Config sublayer: K→karabiner.json, .→~/code/general",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "k",
"modifiers": { "optional": ["any"] }
},
"to": [
{
"shell_command": "/usr/local/bin/code ~/.config/karabiner/karabiner.json"
}
],
"conditions": [
{
"type": "variable_if",
"name": "hyper_sublayer_config",
"value": 1
}
]
},
{
"type": "basic",
"from": {
"key_code": "period",
"modifiers": { "optional": ["any"] }
},
"to": [
{
"shell_command": "/usr/local/bin/code ~/code/general"
}
],
"conditions": [
{
"type": "variable_if",
"name": "hyper_sublayer_config",
"value": 1
}
]
}
]
}
]
},
"name": "Default profile",
"selected": true,
"virtual_hid_keyboard": { "keyboard_type_v2": "ansi" }
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment