-
Notifications
You must be signed in to change notification settings - Fork 125
/
Copy pathrules_test.clj
592 lines (587 loc) · 32 KB
/
rules_test.clj
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
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
(ns karabiner-configurator.rules-test
(:require [karabiner-configurator.rules :as sut]
[karabiner-configurator.data :refer :all]
[clojure.test :as t]))
(def example-mains [{:des "a to 1" :rules [[:condi :chunkwm-move-mode]
[:profiles :Default :test-profile-2]
[:a :1]]} ;; a to 1
{:des "left command a to control 1" :rules [[:!C#Pa :!T1]]}
{:des "right command a to control 1" :rules [[:!Q#Pa :!T1]]} ;; command a to control 1
{:des "my spacebar to control 1" :rules [[:my-spacebar :!T1]]} ;; my-spacebar to control 1
{:des "press b to insert 12" :rules [[:b [:1 :2]]]} ;; key to key
{:des "c to example osascript" :rules [[:c "osascript -e 'display dialog \"example apple script\"'"]]} ;; key to shell script
{:des "d to 1 then example osascript" :rules [[:d [:1 [:example-template "example apple script"]]]]} ;; key to key then shell script
{:des "simultaneous e f to 3" :rules [[[:e :f] :3]]} ;; simultaneous key to key
{:des "g to 4 when variable vi-mode is 1" :rules [[:g :4 :vi-mode]]} ;; vi-mode is 1
{:des "h to 5 when variable vi-mode is not 1" :rules [[:h :5 :!vi-mode]]} ;; vi-mode is not 1
{:des "i to 6 only for device hhkb-bt" :rules [[:i :6 [:hhkb-bt :hhkb]]]} ;; key to key in layer b (in layer a) specific to hhkb-bt device
{:des "j to 7 on hhkb-bt when variable vi-mode is 1" :rules [[:j :7 [:vi-mode :hhkb-bt]]]} ;; multiple condition
{:des "press h insert 8 then set variable some-mode to 0" :rules [[:h [:8 {:set ["some-mode" 0]}]]]}
{:des "capslock to control as modifier to escape when press alone" :rules [[:##caps_lock :left_control nil {:alone :escape}]]}
{:des "Quit application by pressing command-q twice" :rules [[:!C#Pq :!Cq ["command-q" 1]]
[:!C#Pq ["command-q" 1] nil {:delayed {:invoked ["command-q" 0] :canceled ["commandq" 0]}}]]}
{:des "Quit application by holding command-q" :rules [[:!C#Pq nil nil {:held {:key :q :modi :left_command :repeat false}}]]}
{:des "Quit Safari by pressing command-q twice" :rules [[:!C#Pq :!Cq [:safari ["command-q" 1]]]
[:!C#Pq ["command-q" 1] :safari {:delayed {:invoked ["command-q" 0] :canceled ["command-q" 0]}}]]}
{:des "Mouse button"
:rules [[{:pkey :button5} :mission_control]
[{:pkey :button4} [{:pkey :button1} {:pkey :button1} :!!grave_accent_and_tilde]]]}
{:des "Change input source"
:rules [[:i :us :q-mode]
[:o :squirrel :q-mode]]}
{:des "tab-mode"
:rules [:test-profile
:chunkwm-move-mode
[:h "/usr/local/bin/chunkc tiling::window --warp west"]
:Default
:chunkwm-scale-mode
[:h "/usr/local/bin/chunkc tiling::window --use-temporary-ratio 0.03 --adjust-window-edge west"]
[:profiles :test-profile :test-profile-2]
:tab-mode
[:h "/usr/local/bin/chunkc tiling::window --focus west"]
[:condi :chunkwm-move-mode :chunkwm-scale-mode]
[:l "/usr/local/bin/chunkc tiling::window --focus east"]]}
{:des "input source as condition"
:rules [[:a :a :us]]}
{:des "any keycode"
:rules [[{:any :key_code} :a]
[{:any :consumer_key_code} :a]
[{:any :pointing_button} :a]]}
{:des "double press and held key in simlayer (to_delayed_action, to_if_held_down)"
:rules [[:j "say 'j double press'" [["q-mode" 1] ["q-mode-j-dbpress-mode" 1]]]
:q-mode
[:j ["say 'j press down'" ["q-mode-j-dbpress-mode" 1]] nil {:delayed {:canceled ["q-mode-j-dbpress-mode" 0]
:invoked ["q-mode-j-dbpress-mode" 0]}
:held "say 'j held down'"}]]}
{:des "QWER in to right modifier keys" :rules [[:!QWERa :a]]}
{:des "raw rules"
:rules [{:type :mouse_motion_to_scroll :from {:modifiers {:mandatory [:left_control]}}}
{:type :basic :from {:key_code :h :modifiers {:mandatory [:left_control]}} :to [{:key_code :delete_or_backspace}]}]}
{:des "raw rules test-profile"
:rules [:test-profile
{:type :mouse_motion_to_scroll :from {:modifiers {:mandatory [:left_control]}}}
{:type :basic :from {:key_code :h :modifiers {:mandatory [:left_control]}} :to [{:key_code :delete_or_backspace}]}]}])
(def result {:test-profile-2
[{:description "Auto generated layer conditions",
:manipulators
[{:type "basic",
:to [{:set_variable {:name "chunkwm-move-mode", :value 1}}],
:from {:key_code "f"},
:to_after_key_up
[{:set_variable {:name "chunkwm-move-mode", :value 0}}],
:to_if_alone [{:key_code "f"}],
:conditions [{:name "tab-mode", :value 1, :type "variable_if"}]}
{:type "basic",
:to [{:set_variable {:name "tab-mode", :value 1}}],
:from {:key_code "tab"},
:to_after_key_up
[{:set_variable {:name "tab-mode", :value 0}}
{:set_variable {:name "chunkwm-move-mode", :value 0}}
{:set_variable {:name "chunkwm-scale-mode", :value 0}}],
:to_if_alone [{:key_code "tab"}]}
{:type "basic",
:to [{:set_variable {:name "chunkwm-scale-mode", :value 1}}],
:from {:key_code "c"},
:to_after_key_up
[{:set_variable {:name "chunkwm-scale-mode", :value 0}}],
:to_if_alone [{:key_code "c"}],
:conditions [{:name "tab-mode", :value 1, :type "variable_if"}]}]}
{:description "a to 1",
:manipulators
[{:from {:key_code "a"},
:to [{:key_code "1"}],
:conditions
[{:name "chunkwm-move-mode", :value 1, :type "variable_if"}],
:type "basic"}]}
{:description "tab-mode",
:manipulators
[{:from {:key_code "h"},
:to
[{:shell_command
"/usr/local/bin/chunkc tiling::window --focus west"}],
:conditions [{:name "tab-mode", :value 1, :type "variable_if"}],
:type "basic"}
{:from {:key_code "l"},
:to
[{:shell_command
"/usr/local/bin/chunkc tiling::window --focus east"}],
:conditions
[{:name "chunkwm-scale-mode", :value 1, :type "variable_if"}
{:name "chunkwm-move-mode", :value 1, :type "variable_if"}],
:type "basic"}]}],
:Default
[{:description "Auto generated layer conditions",
:manipulators
[{:type "basic",
:to [{:set_variable {:name "chunkwm-move-mode", :value 1}}],
:from {:key_code "f"},
:to_after_key_up
[{:set_variable {:name "chunkwm-move-mode", :value 0}}],
:to_if_alone [{:key_code "f"}],
:conditions [{:name "tab-mode", :value 1, :type "variable_if"}]}
{:type "basic",
:to [{:set_variable {:name "chunkwm-scale-mode", :value 1}}],
:from {:key_code "c"},
:to_after_key_up
[{:set_variable {:name "chunkwm-scale-mode", :value 0}}],
:to_if_alone [{:key_code "c"}],
:conditions [{:name "tab-mode", :value 1, :type "variable_if"}]}]}
{:description "a to 1",
:manipulators
[{:from {:key_code "a"},
:to [{:key_code "1"}],
:conditions
[{:name "chunkwm-move-mode", :value 1, :type "variable_if"}],
:type "basic"}]}
{:description "left command a to control 1",
:manipulators
[{:from
{:key_code "a",
:modifiers
{:mandatory ["left_command"], :optional ["caps_lock"]}},
:to [{:key_code "1", :modifiers ["left_control"]}],
:type "basic"}]}
{:description "right command a to control 1",
:manipulators
[{:from
{:key_code "a",
:modifiers
{:mandatory ["right_command"], :optional ["caps_lock"]}},
:to [{:key_code "1", :modifiers ["left_control"]}],
:type "basic"}]}
{:description "my spacebar to control 1",
:manipulators
[{:from {:key :spacebar},
:to [{:key_code "1", :modifiers ["left_control"]}],
:type "basic"}]}
{:description "press b to insert 12",
:manipulators
[{:from {:key_code "b"},
:to [{:key_code "1"} {:key_code "2"}],
:type "basic"}]}
{:description "c to example osascript",
:manipulators
[{:from {:key_code "c"},
:to
[{:shell_command
"osascript -e 'display dialog \"example apple script\"'"}]
:type "basic"}]}
{:description "d to 1 then example osascript",
:manipulators
[{:from {:key_code "d"},
:to
[{:key_code "1"}
{:shell_command
"osascript -e 'display dialog \"example apple script\" \"\"'"}],
:type "basic"}]}
{:description "simultaneous e f to 3",
:manipulators
[{:from
{:simultaneous [{:key_code "e"} {:key_code "f"}],
:simultaneous_options
{:detect_key_down_uninterruptedly false,
:key_down_order "insensitive",
:key_up_order "insensitive",
:key_up_when "any"}},
:to [{:key_code "3"}],
:type "basic"}]}
{:description "g to 4 when variable vi-mode is 1",
:manipulators
[{:from {:key_code "g"},
:to [{:key_code "4"}],
:conditions [{:name "vi-mode", :value 1, :type "variable_if"}],
:type "basic"}
{:parameters {:basic.simultaneous_threshold_milliseconds 250},
:to [{:set_variable {:name "vi-mode", :value 1}} {:key_code "4"}],
:from
{:simultaneous [{:key_code "d"} {:key_code "g"}],
:simultaneous_options
{:detect_key_down_uninterruptedly true,
:key_down_order "strict",
:key_up_order "strict_inverse",
:key_up_when "any",
:to_after_key_up
[{:set_variable {:name "vi-mode", :value 0}}]}}}]}
{:description "h to 5 when variable vi-mode is not 1",
:manipulators
[{:from {:key_code "h"},
:to [{:key_code "5"}],
:conditions
[{:name "vi-mode", :value 1, :type "variable_unless"}],
:type "basic"}]}
{:description "i to 6 only for device hhkb-bt",
:manipulators
[{:from {:key_code "i"},
:to [{:key_code "6"}],
:conditions
[{:identifiers
[{:vendor_id 1278, :product_id 51966}
{:vendor_id 2131, :product_id 256}],
:type "device_if"}],
:type "basic"}]}
{:description "j to 7 on hhkb-bt when variable vi-mode is 1",
:manipulators
[{:from {:key_code "j"},
:to [{:key_code "7"}],
:conditions
[{:name "vi-mode", :value 1, :type "variable_if"}
{:identifiers [{:vendor_id 1278, :product_id 51966}],
:type "device_if"}],
:type "basic"}
{:parameters {:basic.simultaneous_threshold_milliseconds 250},
:to [{:set_variable {:name "vi-mode", :value 1}} {:key_code "7"}],
:from
{:simultaneous [{:key_code "d"} {:key_code "j"}],
:simultaneous_options
{:detect_key_down_uninterruptedly true,
:key_down_order "strict",
:key_up_order "strict_inverse",
:key_up_when "any",
:to_after_key_up
[{:set_variable {:name "vi-mode", :value 0}}]}}}]}
{:description "press h insert 8 then set variable some-mode to 0",
:manipulators
[{:from {:key_code "h"},
:to
[{:key_code "8"} {:set_variable {:name "some-mode", :value 0}}],
:type "basic"}]}
{:description
"capslock to control as modifier to escape when press alone",
:manipulators
[{:to_if_alone [{:key_code "escape"}],
:from {:key_code "caps_lock", :modifiers {:optional ["any"]}},
:to [{:key_code "left_control"}],
:type "basic"}]}
{:description "Quit application by pressing command-q twice",
:manipulators
[{:from
{:key_code "q",
:modifiers
{:mandatory ["left_command"], :optional ["caps_lock"]}},
:to [{:key_code "q", :modifiers ["left_command"]}],
:conditions [{:name "command-q", :value 1, :type "variable_if"}],
:type "basic"}
{:to_delayed_action
{:to_if_invoked [{:set_variable {:name "command-q", :value 0}}],
:to_if_canceled [{:set_variable {:name "commandq", :value 0}}]},
:from
{:key_code "q",
:modifiers
{:mandatory ["left_command"], :optional ["caps_lock"]}},
:to [{:set_variable {:name "command-q", :value 1}}],
:type "basic"}]}
{:description "Quit application by holding command-q",
:manipulators
[{:to_if_held_down
[{:modifiers ["left_command"], :key_code "q", :repeat false}],
:from
{:key_code "q",
:modifiers
{:mandatory ["left_command"], :optional ["caps_lock"]}},
:type "basic"}]}
{:description "Quit Safari by pressing command-q twice",
:manipulators
[{:from
{:key_code "q",
:modifiers
{:mandatory ["left_command"], :optional ["caps_lock"]}},
:to [{:key_code "q", :modifiers ["left_command"]}],
:conditions
[{:bundle_identifiers ["^com\\.apple\\.Safari$"],
:type "frontmost_application_if"}
{:name "command-q", :value 1, :type "variable_if"}],
:type "basic"}
{:to_delayed_action
{:to_if_invoked [{:set_variable {:name "command-q", :value 0}}],
:to_if_canceled [{:set_variable {:name "command-q", :value 0}}]},
:from
{:key_code "q",
:modifiers
{:mandatory ["left_command"], :optional ["caps_lock"]}},
:to [{:set_variable {:name "command-q", :value 1}}],
:conditions
[{:bundle_identifiers ["^com\\.apple\\.Safari$"],
:type "frontmost_application_if"}],
:type "basic"}]}
{:description "Mouse button",
:manipulators
[{:from {:pointing_button "button5"},
:to [{:key_code "mission_control"}],
:type "basic"}
{:from {:pointing_button "button4"},
:to
[{:pointing_button "button1"}
{:pointing_button "button1"}
{:key_code "grave_accent_and_tilde",
:modifiers
["left_command" "left_control" "left_option" "left_shift"]}],
:type "basic"}]}
{:description "Change input source",
:manipulators
[{:from {:key_code "i"},
:to
[{:select_input_source
{:input_mode_id "",
:input_source_id "com.apple.keylayout.US",
:language "en"}}],
:conditions [{:name "q-mode", :value 1, :type "variable_if"}],
:type "basic"}
{:key :q,
:from
{:simultaneous [{:key_code "i"}],
:simultaneous_options
{:detect_key_down_uninterruptedly false,
:key_down_order "insensitive",
:key_up_order "insensitive",
:key_up_when "any"}},
:to
[{:select_input_source
{:input_mode_id "",
:input_source_id "com.apple.keylayout.US",
:language "en"}}]}
{:from {:key_code "o"},
:to
[{:select_input_source
{:input_mode_id "com.googlecode.rimeime.inputmethod.Squirrel",
:input_source_id
"com.googlecode.rimeime.inputmethod.Squirrel.Rime",
:language "zh-Hans"}}],
:conditions [{:name "q-mode", :value 1, :type "variable_if"}],
:type "basic"}
{:key :q,
:from
{:simultaneous [{:key_code "o"}],
:simultaneous_options
{:detect_key_down_uninterruptedly false,
:key_down_order "insensitive",
:key_up_order "insensitive",
:key_up_when "any"}},
:to
[{:select_input_source
{:input_mode_id "com.googlecode.rimeime.inputmethod.Squirrel",
:input_source_id
"com.googlecode.rimeime.inputmethod.Squirrel.Rime",
:language "zh-Hans"}}]}]}
{:description "tab-mode",
:manipulators
[{:from {:key_code "h"},
:to
[{:shell_command
"/usr/local/bin/chunkc tiling::window --use-temporary-ratio 0.03 --adjust-window-edge west"}],
:conditions
[{:name "chunkwm-scale-mode", :value 1, :type "variable_if"}],
:type "basic"}]}
{:description "input source as condition",
:manipulators
[{:from {:key_code "a"},
:to [{:key_code "a"}],
:conditions
[{:input_sources
[{:input_mode_id "",
:input_source_id "com.apple.keylayout.US",
:language "en"}],
:type "input_source_if"}],
:type "basic"}]}
{:description "any keycode",
:manipulators
[{:from {:any "key_code"}, :to [{:key_code "a"}], :type "basic"}
{:from {:any "consumer_key_code"},
:to [{:key_code "a"}],
:type "basic"}
{:from {:any "pointing_button"},
:to [{:key_code "a"}],
:type "basic"}]}
{:description
"double press and held key in simlayer (to_delayed_action, to_if_held_down)",
:manipulators
[{:from {:key_code "j"},
:to [{:shell_command "say 'j double press'"}],
:conditions
[{:name "q-mode", :value 1, :type "variable_if"}
{:name "q-mode-j-dbpress-mode", :value 1, :type "variable_if"}],
:type "basic"}
{:to_if_held_down [{:shell_command "say 'j held down'"}],
:to_delayed_action
{:to_if_invoked
[{:set_variable {:name "q-mode-j-dbpress-mode", :value 0}}],
:to_if_canceled
[{:set_variable {:name "q-mode-j-dbpress-mode", :value 0}}]},
:from {:key_code "j"},
:to
[{:shell_command "say 'j press down'"}
{:set_variable {:name "q-mode-j-dbpress-mode", :value 1}}],
:conditions [{:name "q-mode", :value 1, :type "variable_if"}],
:type "basic"}
{:key :q,
:from
{:simultaneous [{:key_code "j"}],
:simultaneous_options
{:detect_key_down_uninterruptedly false,
:key_down_order "insensitive",
:key_up_order "insensitive",
:key_up_when "any"}},
:to
[{:shell_command "say 'j press down'"}
{:set_variable {:name "q-mode-j-dbpress-mode", :value 1}}],
:to_if_held_down [{:shell_command "say 'j held down'"}],
:to_delayed_action
{:to_if_invoked
[{:set_variable {:name "q-mode-j-dbpress-mode", :value 0}}],
:to_if_canceled
[{:set_variable {:name "q-mode-j-dbpress-mode", :value 0}}]}}]}
{:description "QWER in to right modifier keys",
:manipulators
[{:from
{:key_code "a",
:modifiers
{:mandatory
["right_command"
"right_control"
"right_option"
"right_shift"]}},
:to [{:key_code "a"}],
:type "basic"}]}
{:description "raw rules",
:manipulators
[{:type :mouse_motion_to_scroll,
:from {:modifiers {:mandatory [:left_control]}}}
{:type :basic,
:from {:key_code :h, :modifiers {:mandatory [:left_control]}},
:to [{:key_code :delete_or_backspace}]}]}],
:test-profile
[{:description "Auto generated layer conditions",
:manipulators
[{:type "basic",
:to [{:set_variable {:name "chunkwm-move-mode", :value 1}}],
:from {:key_code "f"},
:to_after_key_up
[{:set_variable {:name "chunkwm-move-mode", :value 0}}],
:to_if_alone [{:key_code "f"}],
:conditions [{:name "tab-mode", :value 1, :type "variable_if"}]}
{:type "basic",
:to [{:set_variable {:name "tab-mode", :value 1}}],
:from {:key_code "tab"},
:to_after_key_up
[{:set_variable {:name "tab-mode", :value 0}}
{:set_variable {:name "chunkwm-move-mode", :value 0}}
{:set_variable {:name "chunkwm-scale-mode", :value 0}}],
:to_if_alone [{:key_code "tab"}]}
{:type "basic",
:to [{:set_variable {:name "chunkwm-scale-mode", :value 1}}],
:from {:key_code "c"},
:to_after_key_up
[{:set_variable {:name "chunkwm-scale-mode", :value 0}}],
:to_if_alone [{:key_code "c"}],
:conditions [{:name "tab-mode", :value 1, :type "variable_if"}]}]}
{:description "tab-mode",
:manipulators
[{:from {:key_code "h"},
:to
[{:shell_command
"/usr/local/bin/chunkc tiling::window --warp west"}],
:conditions
[{:name "chunkwm-move-mode", :value 1, :type "variable_if"}],
:type "basic"}
{:from {:key_code "h"},
:to
[{:shell_command
"/usr/local/bin/chunkc tiling::window --focus west"}],
:conditions [{:name "tab-mode", :value 1, :type "variable_if"}],
:type "basic"}
{:from {:key_code "l"},
:to
[{:shell_command
"/usr/local/bin/chunkc tiling::window --focus east"}],
:conditions
[{:name "chunkwm-scale-mode", :value 1, :type "variable_if"}
{:name "chunkwm-move-mode", :value 1, :type "variable_if"}],
:type "basic"}]}
{:description "raw rules test-profile",
:manipulators
[{:type :mouse_motion_to_scroll,
:from {:modifiers {:mandatory [:left_control]}}}
{:type :basic,
:from {:key_code :h, :modifiers {:mandatory [:left_control]}},
:to [{:key_code :delete_or_backspace}]}]}]})
(t/deftest generate-mains
(init-conf-data)
(update-conf-data
{:profiles {:Default
{:complex_modifications {:parameters {:basic.simultaneous_threshold_milliseconds 50,
:basic.to_delayed_action_delay_milliseconds 500,
:basic.to_if_alone_timeout_milliseconds 1000,
:basic.to_if_held_down_threshold_milliseconds 500}}}
:test-profile
{:complex_modifications {:parameters {:basic.simultaneous_threshold_milliseconds 50,
:basic.to_delayed_action_delay_milliseconds 500,
:basic.to_if_alone_timeout_milliseconds 1000,
:basic.to_if_held_down_threshold_milliseconds 500}}}
:test-profile-2
{:complex_modifications {:parameters {:basic.simultaneous_threshold_milliseconds 50,
:basic.to_delayed_action_delay_milliseconds 500,
:basic.to_if_alone_timeout_milliseconds 1000,
:basic.to_if_held_down_threshold_milliseconds 500}}}}
:applications {:safari ["^com\\.apple\\.Safari$"]
:chrome ["^com\\.google\\.Chrome$"]
:chrome-canary ["^com\\.google\\.Chrome\\.canary$"]
:chromes ["^com\\.google\\.Chrome$" "^com\\.google\\.Chrome\\.canary$"]}
:devices {:hhkb-bt [{:vendor_id 1278 :product_id 51966}]
:hhkb [{:vendor_id 2131 :product_id 256}]}
:input-sources {:squirrel {:input_mode_id "com.googlecode.rimeime.inputmethod.Squirrel"
:input_source_id "com.googlecode.rimeime.inputmethod.Squirrel.Rime"
:language "zh-Hans"}
:us {:input_mode_id ""
:input_source_id "com.apple.keylayout.US"
:language "en"}}
:templates {:example-template "osascript -e 'display dialog \"%s\" \"%s\"'"}
:modifiers {}
:froms {:my-spacebar {:key :spacebar}}
:tos {}
:layers
{:tab-mode {:type "basic",
:to [{:set_variable {:name "tab-mode", :value 1}}],
:from {:key_code "tab"},
:to_after_key_up [{:set_variable {:name "tab-mode", :value 0}}
{:set_variable {:name "chunkwm-move-mode",
:value 0}}
{:set_variable {:name "chunkwm-scale-mode",
:value 0}}],
:to_if_alone [{:key_code "tab"}]},
:chunkwm-move-mode {:type "basic",
:to [{:set_variable {:name "chunkwm-move-mode",
:value 1}}],
:from {:key_code "f"},
:to_after_key_up [{:set_variable {:name "chunkwm-move-mode",
:value 0}}],
:to_if_alone [{:key_code "f"}],
:conditions [{:name "tab-mode",
:value 1,
:type "variable_if"}]},
:chunkwm-scale-mode {:type "basic",
:to [{:set_variable {:name "chunkwm-scale-mode",
:value 1}}],
:from {:key_code "c"},
:to_after_key_up [{:set_variable {:name "chunkwm-scale-mode",
:value 0}}],
:to_if_alone [{:key_code "c"}],
:conditions [{:name "tab-mode",
:value 1,
:type "variable_if"}]}}
:simlayers {:q-mode {:key :q}
:vi-mode {:parameters {:basic.simultaneous_threshold_milliseconds 250},
:to [{:set ["vi-mode" 1]}],
:from {:sim [:d],
:simo {:interrupt true,
:dorder :strict,
:uorder :strict_inverse,
:afterup {:set ["vi-mode" 0]}}}}
:launcher-mode {:parameters {:basic.simultaneous_threshold_milliseconds 250},
:to [{:set ["vi-mode" 1]}],
:from {:sim [:d],
:simo {:interrupt true,
:dorder :strict,
:uorder :strict_inverse,
:afterup {:set ["vi-mode" 0]}}}}}
:simlayer-threshold 250})
(t/testing
(t/is (= (sut/parse-mains example-mains) result))))