-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.py
60 lines (56 loc) · 1.79 KB
/
generate.py
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
# generate.py
import json
from config import (
From, To, Manipulator, KarabinerRule,
SUBLAYERS, ARC_BROWSER_BINDINGS,
create_hyper_sublayers,
create_arc_browser_rule,
create_device_profile
)
def main():
# Create basic rules
rules = [
KarabinerRule(
description="Hyper Key (⌃⌥⇧⌘)",
manipulators=[
Manipulator(
type="basic",
from_=From(key_code="caps_lock", modifiers={"optional": ["any"]}),
to=[To(set_variable={"name": "hyper", "value": 1})],
to_after_key_up=[To(set_variable={"name": "hyper", "value": 0})],
to_if_alone=[To(key_code="escape")],
description="Caps Lock -> Hyper Key"
)
]
),
*create_hyper_sublayers(SUBLAYERS),
create_arc_browser_rule(ARC_BROWSER_BINDINGS),
]
# Create final configuration
config = {
"global": {
"show_in_menu_bar": False
},
"profiles": [
{
"name": "Default",
"complex_modifications": {
"rules": [rule.to_dict() for rule in rules]
},
"devices": [create_device_profile()],
"virtual_hid_keyboard": {
"keyboard_type_v2": "ansi"
}
}
]
}
# Write configuration to file
try:
with open("karabiner.json", "w") as f:
json.dump(config, f, indent=2)
print("Karabiner configuration has been generated successfully!")
print("Please copy karabiner.json to: ~/.config/karabiner/")
except Exception as e:
print(f"Error generating configuration: {e}")
if __name__ == "__main__":
main()