-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·53 lines (43 loc) · 1.48 KB
/
main.py
File metadata and controls
executable file
·53 lines (43 loc) · 1.48 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
import sys
import threading
import time
from core.monitor import KeyboardMonitor
from core.config_loader import load_config
from core.gui import show_config_window
from core.systray import SystemTrayApp
def start_monitor():
try:
monitor = KeyboardMonitor()
monitor.start()
except Exception as e:
print(f"Monitor Thread Error: {e}")
def main():
print("=== Global Translator Started ===")
# 1. Check Config
try:
config = load_config()
key = config.get('deepseek_api_key')
if not key or key == "YOUR_API_KEY_HERE":
print("No API Key found. Opening settings...")
show_config_window()
# Reload to check if saved
config = load_config()
if not config.get('deepseek_api_key'):
print("Still no API Key. Exiting.")
sys.exit(0)
except FileNotFoundError:
show_config_window()
# 2. Start Monitor in Background Thread
# pynput listener is blocking, so we put it in a thread.
monitor_thread = threading.Thread(target=start_monitor, daemon=True)
monitor_thread.start()
print("Monitor started in background.")
# 3. Start System Tray (Must be on main thread for macOS)
print("Starting System Tray...")
def stop_app():
print("Stopping application...")
sys.exit(0)
tray = SystemTrayApp(stop_callback=stop_app)
tray.run()
if __name__ == "__main__":
main()