-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
51 lines (37 loc) · 1.12 KB
/
app.py
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
from os import system, path
from PyQt5.QtCore import QTimer
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication
from fetcher import Fetcher
from preferences import Preferences
from tray import Tray
app = QApplication([])
ICON_PATH = f"{path.abspath(path.curdir)}/icon.png"
# Create the icon
icon = QIcon(ICON_PATH)
app.setQuitOnLastWindowClosed(False)
# Create the tray
settings = Preferences()
tray = Tray(icon, settings)
fetcher = Fetcher(settings)
# tray.activated.connect(lambda ev: print(ev))
timer = QTimer()
timer.setSingleShot(False)
timer.setInterval(60 * 1000)
def notify_time(time, delay=None):
if not delay:
command = f"notify-send -i {ICON_PATH} '{time}'"
else:
command = f"notify-send -i {ICON_PATH} 'Le métro de {time} part dans {delay} minutes'"
system(command)
def update():
times = fetcher.update_settings(notify_time)
tray.update_times(times)
timer.timeout.connect(update)
tray.quit.triggered.connect(app.quit)
tray.refresh.triggered.connect(update)
if __name__ == "__main__":
update()
timer.start()
notify_time("Starting valencia")
app.exec_()