-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path11_hotkey_daemon.py
More file actions
42 lines (32 loc) · 1.03 KB
/
11_hotkey_daemon.py
File metadata and controls
42 lines (32 loc) · 1.03 KB
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
"""Bind global hotkeys to JSON action files.
The daemon runs in a background thread, listening on the OS's
hotkey API. ``combo`` syntax matches the GUI's Hotkeys tab —
``ctrl+shift+f9`` style. Each binding points at a JSON action file
that the executor runs when the combo fires.
"""
import json
import time
from pathlib import Path
import je_auto_control as ac
SCRIPT = Path(__file__).with_name("on_hotkey.json")
def main() -> None:
SCRIPT.write_text(
json.dumps([
["AC_screenshot", {"file_path": "hotkey_capture.png"}],
]),
encoding="utf-8",
)
daemon = ac.default_hotkey_daemon
binding = daemon.bind("ctrl+shift+f9", str(SCRIPT))
print(f"bound {binding.combo} → {binding.script_path}")
daemon.start()
print("daemon running — press Ctrl+Shift+F9 to capture, Ctrl-C here to stop.")
try:
while True:
time.sleep(1.0)
except KeyboardInterrupt:
print("\nstopping…")
finally:
daemon.stop()
if __name__ == "__main__":
main()