-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconf.rb
116 lines (110 loc) · 2.22 KB
/
conf.rb
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
require './karabiner'
module Conf
module_function
def basic_rules
[
Rule.gen(
"(internal) fn-caps_lock: caps_lock",
[{
from: {
key_code: "caps_lock",
modifiers: ModFrom.mandatory_fn,
},
to: [{key_code: "caps_lock"}],
}],
),
Rule.gen(
'(internal) caps_lock: escape, left_control',
[{
from: {
key_code: 'caps_lock',
modifiers: ModFrom.optional_not_fn,
},
to: [{ key_code: "left_control"}],
to_if_alone: [{ key_code: "escape"}],
}]
),
Rule.gen(
'(internal) left_command: f8, left_gui',
[{
from: {
key_code: 'left_gui',
modifiers: ModFrom.optional_any
},
to: [{ key_code: "left_gui"}],
to_if_alone: [{ key_code: "f8"}],
}]
),
]
end
# Layer1
def layer1_trigger
"spacebar"
end
def layer1_mods
[
"command",
"control",
]
end
def layer1_keys
KeyRegion.whole
end
# Layer2
def layer2_trigger
"tab"
end
def layer2_mods
[
"command",
"option",
"control",
]
end
def layer2_keys
KeyRegion.whole
end
# Layer3
def layer3_trigger
"grave_accent_and_tilde"
end
def layer3_mods
[
"control",
"shift",
"option",
]
end
def layer3_keys
KeyRegion.below
end
# final conf
def layers
[
Layer1.new(layer1_trigger, layer1_mods, layer1_keys),
Layer2.new(layer2_trigger, layer2_mods, layer2_keys),
Layer3.new(layer3_trigger, layer3_mods, layer3_keys, ModFrom.optional_not_shift),
]
end
def gen_rules()
layers.inject(basic_rules) { |acc, layer| acc + layer.gen_rules }
end
def gen()
{
global: {
check_for_updates_on_startup: true,
show_in_menu_bar: false,
show_profile_name_in_menu_bar: false,
},
profiles: [{
complex_modifications: {
parameters: {
"basic.to_if_alone_timeout_milliseconds": 500,
"basic.to_delayed_action_delay_milliseconds": 500,
},
rules: gen_rules()
}
}]
}
end
end