Skip to main content

karabiner.ts

Karabiner-Elements configuration file is in JSON format.

~/.config/karabiner/karabiner.json
{
"profiles": [
{
"name": "Default", // 1
"complex_modifications": {
"rules": [ // 2
{
"description": "Demo Rule",
"manipulators": [ // 3
{
"type": "basic",
"from": { "key_code": "caps_lock" }, // 4
"to": [ // 5
{"key_code": "delete_or_backspace", "modifiers": ["command"]}
],
"conditions": [ // 6
{"type": "variable_if", "name": "test", "value": 1}
]
}
]
}
]
}
}
]
}

karabiner.ts allows you to write complex_modifications in TypeScript:

writeToProfile('Default', [ // 1 profile to config complex_modifications
rule('Demo Rule') // 2 rules
.manipulators([ // 3 manipulators
map('⇪') // 4 from
.to('⌫', '⌘') // 5 to
.condition(ifVar('test')), // 6 conditions
]),
])