-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·48 lines (37 loc) · 1.5 KB
/
Copy pathmain.py
File metadata and controls
executable file
·48 lines (37 loc) · 1.5 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
import sys
import os
from PyQt6.QtWidgets import QApplication, QSystemTrayIcon, QMenu
from PyQt6.QtGui import QIcon, QAction
from timer import PomodoroTimer
from config import read_timer_config, ensure_config_exists
def resource_path(relative_path):
try:
base_path = sys._MEIPASS
except AttributeError:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
if __name__ == "__main__":
ensure_config_exists()
config = read_timer_config()
work_time = config.get("work_duration", 25)
break_time = config.get("break_duration", 5)
long_break_duration = config.get("long_break_duration", 15)
theme = config.get("theme", "light")
app = QApplication(sys.argv)
window = PomodoroTimer(work_time, break_time, long_break_duration)
tray_icon = QSystemTrayIcon(QIcon(resource_path("assets/tray.png" if theme == "light" else "assets/tray_dark.png")), parent=app)
menu = QMenu()
restore_action = QAction("Restore")
restore_action.triggered.connect(window.show)
menu.addAction(restore_action)
hide_action = QAction("Hide")
hide_action.triggered.connect(window.hide)
menu.addAction(hide_action)
exit_action = QAction("Exit")
exit_action.triggered.connect(app.quit)
menu.addAction(exit_action)
tray_icon.setContextMenu(menu)
tray_icon.activated.connect(lambda reason: window.show() if reason == QSystemTrayIcon.ActivationReason.Trigger else None)
tray_icon.show()
window.show()
sys.exit(app.exec())