2019-10-21 00:14:56 +03:00
|
|
|
#!/usr/bin/python3
|
|
|
|
import notify2
|
|
|
|
from time import sleep
|
2019-10-21 14:14:15 +03:00
|
|
|
from playsound import playsound
|
2019-10-21 00:14:56 +03:00
|
|
|
|
|
|
|
NAME = 'Eye Strain Reminder'
|
|
|
|
MESSAGE = 'Friendly reminder to observe the 20-20-20 rule'
|
|
|
|
TIMEOUT = 20
|
|
|
|
MILLISECOND = 1000
|
2019-10-22 13:55:16 +03:00
|
|
|
MINUTE = 60
|
2019-10-21 00:14:56 +03:00
|
|
|
|
|
|
|
def init():
|
|
|
|
notify2.init(NAME)
|
|
|
|
|
|
|
|
def uninit():
|
|
|
|
notify2.uninit()
|
|
|
|
|
2019-10-22 13:55:16 +03:00
|
|
|
def wait():
|
|
|
|
sleep(TIMEOUT*MINUTE)
|
|
|
|
|
2019-10-21 00:14:56 +03:00
|
|
|
def send_notification():
|
2019-10-21 14:14:15 +03:00
|
|
|
notification = notify2.Notification(NAME, MESSAGE, "notification-device-eject")
|
2019-10-21 00:14:56 +03:00
|
|
|
notification.set_timeout(TIMEOUT * MILLISECOND)
|
|
|
|
notification.set_urgency(notify2.URGENCY_LOW)
|
|
|
|
notification.show()
|
2019-10-21 14:14:15 +03:00
|
|
|
playsound('files/default.wav')
|
2019-10-21 00:14:56 +03:00
|
|
|
sleep(TIMEOUT)
|
|
|
|
notification.close()
|
2019-10-21 14:14:15 +03:00
|
|
|
playsound('files/default.wav')
|
2019-10-21 00:14:56 +03:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
init()
|
2019-10-22 13:55:16 +03:00
|
|
|
while 1:
|
|
|
|
wait()
|
|
|
|
send_notification()
|
2019-10-21 00:14:56 +03:00
|
|
|
uninit()
|