-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkarabiner_gen.js
executable file
·52 lines (45 loc) · 1.3 KB
/
karabiner_gen.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env node
const capsToEsc = {
description: 'Remap capslock to escape. Tapping both shifts sends capslock.',
manipulators: [
{
type: 'basic',
from: { key_code: 'caps_lock', modifiers: { 'optional': [ 'any' ] } },
to: [ { key_code: 'escape' } ]
},
{
type: 'basic',
from: { key_code: 'left_shift', modifiers: { mandatory: [ 'right_shift' ], optional: [ 'caps_lock' ] } },
to: [ { key_code: 'caps_lock' } ]
},
{
type: 'basic',
from: { key_code: 'right_shift', modifiers: { mandatory: [ 'left_shift' ], optional: [ 'caps_lock' ] } },
to: [ { key_code: 'caps_lock' } ]
}
]
}
const fnAsCtrlWith = key => ({
type: 'basic',
from: { key_code: key, modifiers: { mandatory: ['fn'], optional: ['any'] } },
to: [ { key_code: key, modifiers: ['left_control'] } ]
})
const letterKeys = 'abcdefghijklmnopqrstuvwxyz'.split('')
const fnToCtrl = {
description: 'Remap fn to left_control when pressed with keys that do something in combination with left_control',
manipulators: [
...letterKeys,
'spacebar',
'return_or_enter',
'close_bracket',
'open_bracket'
].map(fnAsCtrlWith)
}
const config = {
'title': 'My custom rules',
'rules': [
capsToEsc,
fnToCtrl
]
}
console.log(JSON.stringify(config, null, 2))