-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathheadless_runner.py
More file actions
66 lines (54 loc) · 1.58 KB
/
headless_runner.py
File metadata and controls
66 lines (54 loc) · 1.58 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import signal
import keyboard
import time
from recorder.recorder import ManualRecorder
from recorder.replay_buffer import ReplayBuffer
from recorder.screenshot import take_screenshot
manual = ManualRecorder()
replay = ReplayBuffer()
replay.start()
# Track states
recording = False
def toggle_recording():
global recording
if recording:
print("[Hotkey] Stopping manual recording...")
manual.stop()
else:
print("[Hotkey] Starting manual recording...")
manual.start()
recording = not recording
def save_instant_replay():
print("[Hotkey] Saving instant replay...")
replay.save_replay()
def capture_screenshot():
print("[Hotkey] Capturing screenshot...")
take_screenshot()
def graceful_shutdown(*_):
print("\n[!] Caught exit signal. Cleaning up...")
if recording:
manual.stop()
replay.stop()
print("✅ Shutdown complete. Bye!")
exit(0)
# Register signal handlers
signal.signal(signal.SIGINT, graceful_shutdown)
signal.signal(signal.SIGTERM, graceful_shutdown)
# Hotkeys
keyboard.add_hotkey("ctrl+alt+r", toggle_recording)
keyboard.add_hotkey("ctrl+alt+i", save_instant_replay)
keyboard.add_hotkey("ctrl+alt+s", capture_screenshot)
print("""
🎮 Shadow Recorder is running...
🔴 Ctrl + Alt + R → Start/Stop manual recording
📸 Ctrl + Alt + S → Take screenshot
⏪ Ctrl + Alt + I → Save instant replay
❌ Ctrl + C → Exit gracefully
(Leave this terminal open while recording)
""")
# Keep script alive
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
graceful_shutdown()