-
Notifications
You must be signed in to change notification settings - Fork 0
/
.karabiner.edn
519 lines (430 loc) · 18.5 KB
/
.karabiner.edn
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
{
;; I've written extensively about this script/goku/karabiner over at my blog
;; You might find this post particularly helpful:
;;
;; https://kau.sh/blog/hacking-your-keyboard/
;;
;; :!Ca is keycode :a and prefix a with !C
;; C | left_command
;; T | left_control
;; O | left_option
;; S | left_shift
;; F | fn
;; Q | right_command
;; W | right_control
;; E | right_option
;; R | right_shift
;; P | caps_lock
;; !! | command + control + optional + shift (hyper)
;; code for all this:
;; https://github.com/yqrashawn/GokuRakuJoudo/blob/b9b334a187379f9bc8182ad59e2cca2a1789e9c0/src/karabiner_configurator/keys.clj#L68
;; FROM modifiers
;; to understand better how modifiers work in karabiner
;; karabiner definition of mandatory and optional
;; https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/from/modifiers/
;; | no modifier
;; input key maps to output key exactly
;; adding any modifier will cancel the event
;; ! | mandatory
;; specified modifier is removed in output (to event)
;; specified modifiers must be present for event to occur
;; adding any other modifier will cancel the event
;; # | optional (single)
;; specified modifier is kept in output (to event)
;; one (or none) of the specified modifiers must be present
;; adding any other modifier will cancel the event
;; ## | optional any
;; specified modifier is removed in output (to event)
;; specified modifiers *must* be present for event to occur
;; adding any other modifier will add to output event
;; (what you typically expect, additional modifiers tacked on)
;;
;; need to prefix C T O S F with ! or #
;;
:profiles {
:Default {
:default true
:sim 25 ;; simultaneous key press threshold (def: 50)
;; simlayer is implemented with to_if_alone and simultaneous key press feature
;; if keydown event for two different keys are pressed within :sim ms, the keypresses are considered simultaneous
:delay 10 ;; to_delayed_action_delay_milliseconds (def: 500)
;; checkout karabiner's documentation
;; https://pqrs.org/osx/karabiner/json.html
;; basically it means time after which the key press is count delayed
;; after :delay ms, the key press is considered to be delayed
;; (used for double-press macros)
:alone 250 ;; to_if_alone_timeout_milliseconds (def: 1000)
;; https://pqrs.org/osx/karabiner/json.html#to-if-alone
;; affects to_if_alone behavior
;; simlayer is implemented with to_if_alone and simultaneous key press feature
;; if keyup event comes within :alone ms from keydown, the key is not just pressed but held
:held 500 ;; to_if_held_down_threshold_milliseconds (def: 500)
;; key is fired twice when :held ms is elapsed (otherwise seen as a hold command) (TODO WHAT IS THIS??)
}
} ;; profiles
; the default value is 250
:simlayer-threshold 250
:templates {
:km "osascript -e 'tell application \"Keyboard Maestro Engine\" to do script \"%s\"'"
:open "open \"%s\""
} ;; templates
;; Define different kinds of keyboards
;; https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/conditions/device/
:devices {
:apple [
{:vendor_id 1452}
{:vendor_id 76}
{:is_built_in_keyboard true}
]
:ap2 [{:vendor_id 1241, :product_id 41618 }] ;; Anne Pro 2 (mechanical)
:msft [{:vendor_id 1118, :product_id 1957 }] ;; Microsoft Keyboard [Ergonomic Sculpt]
:tada68 [{:vendor_id 65261, :product_id 4611 }] ;; Tada68 (mechanical)
:kinesis [{:vendor_id 10730 }] ;; Kinesis Advantage 2 keyboard
:g915 [{:vendor_id 1133}] ;; Logitech G915 keyboard
:kybs [ ;; Default for all keyboards
{:vendor_id 1452}
{:vendor_id 76}
{:vendor_id 1241, :product_id 41618 }
{:vendor_id 1118, :product_id 1957 }
{:vendor_id 65261, :product_id 4611 }
{:vendor_id 10730}
{:vendor_id 1133, :product_id 50501 }
]
:kybs-kinesis [ ;; All keyboards (except Kinesis)
{:vendor_id 1452}
{:vendor_id 76}
{:vendor_id 1241, :product_id 41618 }
{:vendor_id 1118, :product_id 1957 }
{:vendor_id 65261, :product_id 4611 }
{:vendor_id 1133, :product_id 50501 }
]
} ;; devices
;; layers are basically "hyper" keys
;; press this in combination with something else and depending on your rule, make things happen
:layers {
;; :tab-mode {:key :tab}
;; :caps-mode {:key :caps_lock :alone {:key :escape}}
} ;; layers
;; simlayers are basically "hyper" keys
;; layers works too, but only recommended for non-typing keys like . or tab
;; to use more regular typing keys, use simlayers
:simlayers {
:j-mode {:key :j}
:f-mode {:key :f}
} ;; simlayers
:applications {
:terminals [ "^com\\.apple\\.Terminal$",
"^com\\.googlecode\\.iterm2$"]
:intellij [ "com.google.android.studio",
"^com\\.jetbrains\\..*$"]
}
;; main contains multiple manipulators
:main [
;; each manipulator has a description and multiple rules
;;{:des "..." ;; -> description
;; :rules[
;; [<from> <to> <conditions>] ;; -> rule 1
;; [<from> <to> <conditions>] ;; -> rule 2
;; ]}
;; rule [:period ["period-mode" 1] nil {:afterup ["period-mode" 0] :alone :period}]
;; |_____| |_______________| |_| |_________________________________________|
;; <from> <to> <conditions> <other options>
;;
;; karabiner docs: ;; https://pqrs.org/osx/karabiner/json.html#complex_modifications-manipulator-definition
;; <other options> includs ~to_if_alone~, ~to_if_held_down~,~to_after_key_up~, ~to_delayed_action~ and ~parameters~.
;;
;; (custom variables) & modifiers -> Advanced
;; https://github.com/yqrashawn/GokuRakuJoudo/blob/master/examples.org#custom-variable
;; ----------------------------------
;; Hardware keyboard mappings
;; ----------------------------------
;; {:des "Anne Pro 2"
;; :rules [:ap2
;; [:left_option :left_command]
;; [:left_command :left_option]
;; [:right_option :right_control]
;; ]}
;; {:des "Tada68 specific mappings"
;; :rules [:tada68
;; [:delete_forward :end]
;; [:escape :grave_accent_and_tilde]
;; [:grave_accent_and_tilde :home]
;; [:left_gui :left_alt]
;; ]}
;;
;; {:des "Microsoft Ergonomic Sculpt Keyboard"
;; :rules [:msft
;; [:delete_forward :end]
;; [:escape :grave_accent_and_tilde]
;; [:grave_accent_and_tilde :home]
;; [:left_gui :left_alt]
;; ]}
;;
;; {:des "Logitech G915 remap"
;; :rules [:g915
;; [:##right_option :right_control]
;; [:##left_option :left_command]
;; [:##left_command :left_option]
;; ]}
{:des "Kinesis Advantage2 specific mappings"
:rules [:kinesis
[:non_us_backslash :!QWspacebar] ;; § -> emoji viewer
[:open_bracket :backslash] ;; [ -> \
[:close_bracket :slash] ;; ] -> /
]}
;; ----------------------------------
;; ----------------------------------
;; Key mappings
;; ----------------------------------
;; ----------------------------------
{:des "Right Cmd (alone) -> Enter"
:rules [ :apple
[:##right_command :right_control nil {:alone [:return_or_enter]}]
]}
;; -----------------------------------------
;; caps-mode
;; -----------------------------------------
{:des "Caps Lock -> Escape (alone) | Ctrl (simple)"
:rules [
[:##caps_lock :right_control nil {:alone [:escape]}]
;; P | caps_lock
;; W | right_control
;; C | left_command
;; Q | right_command
;; E | right_option
;; O | left_option
;; R | right_shift
;; S | left_shift
;; vim like arrow key mappings
[:!Wh :left_arrow]
[:!Wj :down_arrow]
[:!Wk :up_arrow ]
[:!Wl :right_arrow]
;; Modifier + arrow keys
;; triggering them with caps-lock requires explicit mapping
;; (W) left_command + arrow keys
[:!WCh :!Cleft_arrow]
[:!WCj :!Cdown_arrow]
[:!WCk :!Cup_arrow ]
[:!WCl :!Cright_arrow]
;; (W) left_shift + arrow keys
[:!WSh :!Sleft_arrow]
[:!WSl :!Sright_arrow]
[:!WSh :!Sleft_arrow]
[:!WSk :!Sup_arrow ]
[:!WSj :!Sdown_arrow :!intellij]
[:!WSj :!TSj :intellij] ;; special for intellij (join line)
;; (W) left_option + arrow keys
[:!WOh :!Oleft_arrow]
[:!WOj :!Odown_arrow]
[:!WOk :!Oup_arrow ]
[:!WOl :!Oright_arrow]
;; (W) left_command + left_option + arrow keys
[:!WCOh :!COleft_arrow]
[:!WCOj :!COdown_arrow]
[:!WCOk :!COup_arrow ]
[:!WCOl :!COright_arrow]
;; (W) left_command + left_shift + arrow keys
[:!WSCh :!SCleft_arrow]
[:!WSCj :!SCdown_arrow]
[:!WSCk :!SCup_arrow ]
[:!WSCl :!SCright_arrow]
;; Quick Mouse handles
[:!Wdown_arrow {:mkey {:y 1536}} ]
[:!Wup_arrow {:mkey {:y -1536}} ]
[:!Wleft_arrow {:mkey {:x -1536}} ]
[:!Wright_arrow {:mkey {:x 1536}} ]
[:!Wreturn_or_enter {:pkey :button1} ]
[:!CWreturn_or_enter {:pkey :button2}]
]}
;; {:des "Caps Lock -> Escape | Ctrl | Vim movements | Mouse movement"
;; :rules [ :caps-mode
;;
;; ;[:caps_lock ["caps-mode" 1] nil {:afterup ["caps-mode" 0] :alone :escape}]
;; ; [:h :left_arrow ["caps-mode" 1]]
;;
;; ;; caps lock : arrow mode
;; [:h :left_arrow]
;; [:j :down_arrow]
;; [:k :up_arrow ]
;; [:l :right_arrow]
;;
;; ;; Quick Mouse handles
;; [:down_arrow {:mkey {:y 1536}} ]
;; [:up_arrow {:mkey {:y -1536}} ]
;; [:left_arrow {:mkey {:x -1536}} ]
;; [:right_arrow {:mkey {:x 1536}} ]
;; [:return_or_enter {:pkey :button1} ]
;; [:!Creturn_or_enter {:pkey :button2}]
;;
;; ;; Ctrl handles
;; [:!Sj [:!TSj]] ;; Ctrl Shift J
;;
;; [:a [:!Ta]] ;; Ctrl a
;; [:b [:!Tb]] ;; Ctrl b
;; [:c [:!Tc]] ;; Ctrl c
;; [:d [:!Td]] ;; Ctrl d
;; [:e [:!Te]] ;; Ctrl e
;; [:f [:!Tf]] ;; Ctrl f
;; [:g [:!Tg]] ;; Ctrl g
;; [:i [:!Ti]] ;; Ctrl i
;; [:m [:!Tm]] ;; Ctrl m
;; [:n [:!Tn]] ;; Ctrl n
;; [:o [:!To]] ;; Ctrl o
;; [:p [:!Tp]] ;; Ctrl p
;; [:q [:!Tq]] ;; Ctrl q
;; [:r [:!Tr]] ;; Ctrl r
;; [:s [:!Ts]] ;; Ctrl s
;; [:t [:!Tt]] ;; Ctrl t
;; [:u [:!Tu]] ;; Ctrl u
;; [:v [:!Tv]] ;; Ctrl v
;; [:w [:!Tw]] ;; Ctrl w
;; [:x [:!Tx]] ;; Ctrl x
;; [:y [:!Ty]] ;; Ctrl y
;; [:z [:!Tz]] ;; Ctrl z
;; ]}
;; -----------------------------------------
;; j-mode (deletion related shortcuts)
;; -----------------------------------------
{:des "j-mode (deletion related shortcuts)"
:rules [:j-mode
;; s d f ||| line word char
;; delete line
[:s :!Tu :terminals]
[:s :!Cdelete_or_backspace :!terminals]
;; delete word
[:d :!Tw :terminals]
[:d :!Odelete_or_backspace :!terminals]
;; delete char | backspace
[:f :delete_or_backspace]
;; Command + {} move next/prev tag
[:l :!CSopen_bracket ]
[:semicolon :!CSclose_bracket]
]}
;; -----------------------------------------
;; f-mode (special characters)
;; -----------------------------------------
{:des "f-mode (special characters) ... mostly"
:rules [
;; u i o p
;; - + = *
[:u :hyphen :f-mode]
[:i :!Sequal_sign :f-mode]
[:o :equal_sign :f-mode]
[:p :!S8 :f-mode]
;; m ,
;; [ ]
[:m :open_bracket :f-mode]
[:comma :close_bracket :f-mode]
;; [:j :open_bracket :f-mode]
;; [:k :close_bracket :f-mode]
;; j k
;; ( )
;; [:m :!S9 :f-mode]
;; [:comma :!S0 :f-mode]
[:j :!S9 :f-mode]
[:k :!S0 :f-mode]
;; . /
;; { }
[:period :!Sopen_bracket :f-mode]
[:slash :!Sclose_bracket :f-mode]
; ;
; ,
; this is helpful in vim (find forward / find backward)
[:semicolon :comma :f-mode]
]}
; {:des "testing"
; :rules [
; ;; [{:pkey :button2 :modi :any :lazy true} :left_arrow]
; ;; Alt -> Hyper
; ;; [:##right_alt :!QWEright_shift]
; ;; easier reach to modifier keys
; ;;[:##slash :right_command nil {:alone :slash}]
; ;; [:##z :left_control nil {:alone :z}]
; ;; easier key launches
; ;;[[:f :j] :!Ospacebar] ;; alfred
; ;; Alt -> [] or Meh(Control Shift Option): secondary thumb keys
; ;; [:right_alt :!CTOleft_shift :apple]
; ;; [:##application :!TOleft_shift :g915]
; ; [:##left_control :!TOleft_shift :apple]
; ;; {}
; ;; [:comma :!Sopen_bracket :d-mode]
; ;; [:period :!Sclose_bracket :d-mode]
; ;[:left_shift :left_shift nil {:alone :!Sopen_bracket }]
; ;[:right_shift :right_shift nil {:alone :!Sclose_bracket }]
; ;[:##left_option :left_command :g915 {:alone :!S9 }]
; ;[:##right_option :right_control :g915 {:alone :!S0 }]
;; ;; "close application by pressing command-w twice"
;; [:!C#Pw [:!Cw ["command-w" 0] [:noti :cmdw]] ["command-w" 1]]
;; [:!C#Pw [[:noti :cmdw "Press Again to CLOSE"] ["command-w" 1]] nil {:delayed {:invoked [["command-w" 0] [:noti :cmdw]] :canceled [["command-w" 0] [:noti :cmdw]]}} ]
; ]
;; k → {
;; kk → }
; :rules [:f-mode
; [
; :k
; [:!Sclose_bracket ["dmode-curlyb" 0]]
; ["dmode-curlyb" 1]
; ]
;
; [
; :k
; [["dmode-curlyb" 1]]
; nil
; {
; :delayed
; {
; :invoked [["dmode-curlyb" 0] :!Sopen_bracket]
; :canceled [["dmode-curlyb" 0]]
; }
; }
; ]
; [:k [:km "trigger macro by name"] ] ;; keyboard maestro
; ; training wheels
; [:delete_or_backspace :vk_none]
; ]
; }
;; {:des "Confirm destructive actions like quit/close twice"
;; :rules [
;; ;; full explanation for how this works
;; ;; https://github.com/yqrashawn/GokuRakuJoudo/blob/a77cccb8e8d4e6a9fb8ef2e6bcfe49a4299e4cb2/examples.org#command-q-twice-to-quit-application
;; [
;; ;; <from> second cmd-q (when variable "command-q" is 1)
;; :!C#Pq
;; ;; <to>, 3 to action
;; ;; 1. call cmd-q
;; ;; 2. set variable "command-q" to 0
;; ;; 3. cleanup the :cmdq notification (omit the thrid item to cleanup notification)
;; [:!Cq ["command-q" 0] [:noti :cmdq]]
;; ;; <condition> when variable "command-q" is 1
;; ["command-q" 1]
;; ]
;; [
;; ;; <from> first cmd-q (when variable "command-q" is 0)
;; :!C#Pq
;; ;; <to>, 2 to action
;; ;; 1. show notification with :id :cmdq, :text "Press Again to QUIT"
;; ;; 2. set variable "command-q" to 1 (for the second press)
;; [[:noti :cmdq "Press Again to QUIT"] ["command-q" 1]]
;; ;; <condition> nil means no required condition
;; nil
;; ;; <additional-option>
;; {
;; ;; to_delayed_action documentation
;; ;; https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/to-delayed-action/
;; :delayed
;; {
;; ;; run 2 actions when no other key presses after basic.to_delayed_action_delay_milliseconds
;; ;; 1. set variable "command-q" to 0
;; ;; 2. cleanup notification :id :cmdq
;; :invoked [["command-q" 0] [:noti :cmdq]]
;; ;; run 2 actions when another key presses within basic.to_delayed_action_delay_milliseconds
;; ;; 1. set variable "command-q" to 0
;; ;; 2. cleanup notification :id :cmdq
;; :canceled [["command-q" 0] [:noti :cmdq]]
;; }
;; }
;; ]
;; ]}
] ;; main list
}