-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·130 lines (107 loc) · 4.49 KB
/
main.py
File metadata and controls
executable file
·130 lines (107 loc) · 4.49 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
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
#!/usr/bin/env python3 -u
"""
Stream Deck Dual Control - Control two macOS computers with one Stream Deck
"""
import sys
import os
from pathlib import Path
# Force unbuffered output
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 1)
sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 1)
# Add src to path
sys.path.insert(0, str(Path(__file__).parent))
from src.streamdeck_controller import StreamDeckController
from src.image_manager import ImageManager
from src.notification_helper import notify_crash, notify_startup_error
def create_placeholder_images():
"""Create placeholder images for testing."""
print("Creating placeholder images...")
# Create a temporary deck-like object for image manager
class FakeDeck:
def key_image_format(self):
return {'size': (72, 72)}
fake_deck = FakeDeck()
image_manager = ImageManager(fake_deck)
image_manager.create_placeholder_images()
# Create mode-specific placeholder images
mode_images = {
# Terminal mode
"images/modes/terminal/new-tab.png": ("NT", (0, 200, 100)),
"images/modes/terminal/clear.png": ("CL", (255, 100, 100)),
"images/modes/terminal/git-status.png": ("GS", (100, 100, 255)),
"images/modes/terminal/projects.png": ("PR", (200, 200, 0)),
"images/modes/terminal/ssh.png": ("SSH", (255, 150, 0)),
"images/modes/terminal/python.png": ("PY", (50, 100, 200)),
"images/modes/terminal/node.png": ("JS", (100, 200, 50)),
"images/modes/terminal/docker.png": ("DK", (0, 150, 255)),
"images/modes/terminal/logs.png": ("LOG", (150, 150, 150)),
# Simulator mode
"images/modes/simulator/iphone15.png": ("15", (0, 122, 255)),
"images/modes/simulator/iphonese.png": ("SE", (100, 100, 100)),
"images/modes/simulator/ipadpro.png": ("iPad", (200, 200, 200)),
"images/modes/simulator/screenshot.png": ("📷", (255, 0, 255)),
"images/modes/simulator/home.png": ("🏠", (0, 200, 0)),
"images/modes/simulator/rotate.png": ("↻", (255, 150, 0)),
"images/modes/simulator/reset.png": ("RST", (255, 0, 0)),
"images/modes/simulator/darkmode.png": ("🌙", (50, 50, 50)),
"images/modes/simulator/lightmode.png": ("☀️", (255, 255, 100)),
# Fork mode
"images/modes/fork/fetch.png": ("⬇", (0, 200, 200)),
"images/modes/fork/pull.png": ("⬇⬇", (0, 150, 150)),
"images/modes/fork/push.png": ("⬆", (200, 0, 200)),
"images/modes/fork/commit.png": ("✓", (0, 255, 0)),
"images/modes/fork/stash.png": ("📦", (200, 150, 100)),
"images/modes/fork/branch.png": ("⑂", (150, 100, 200)),
"images/modes/fork/history.png": ("📜", (150, 150, 100)),
"images/modes/fork/diff.png": ("±", (255, 200, 0)),
"images/modes/fork/refresh.png": ("⟳", (100, 200, 255)),
}
for path, (text, color) in mode_images.items():
img = image_manager._create_icon_image(text, color)
full_path = Path(path)
full_path.parent.mkdir(parents=True, exist_ok=True)
img.save(full_path, "PNG")
print("Placeholder images created!")
def main():
"""Main entry point."""
# Clear the log file at startup
log_file = os.path.expanduser("~/.streamdeck.log")
try:
with open(log_file, 'w') as f:
f.write("") # Clear the log
except Exception:
pass # Ignore errors if log file doesn't exist or can't be written
print("Stream Deck Dual Control")
print("=" * 50)
# Check command line arguments
verbose = False
for arg in sys.argv[1:]:
if arg in ["-v", "--verbose"]:
verbose = True
print("VERBOSE MODE ENABLED")
elif arg == "--create-images":
create_placeholder_images()
return
# Create controller with verbose mode
controller = StreamDeckController(verbose=verbose)
# Connect to Stream Deck
if not controller.connect():
print("Failed to connect to Stream Deck!")
sys.exit(1)
# Setup buttons
print("Setting up buttons...")
controller.setup_buttons()
# Run the controller
try:
controller.run()
except KeyboardInterrupt:
print("\nShutting down...")
controller.cleanup()
except Exception as e:
error_msg = str(e)
print(f"Error: {error_msg}")
notify_crash(error_msg)
controller.cleanup()
sys.exit(1)
if __name__ == "__main__":
main()