Functional sleep loop
This commit is contained in:
parent
12dc22372d
commit
bba5143434
|
@ -1,6 +1,6 @@
|
|||
# EyeStrainReminder
|
||||
|
||||
A small background tool to remind the user of the "20-20-20" rule.
|
||||
A small background tool to remind the user of the "20-20-20" rule. Uses system notifications and sound cues.
|
||||
|
||||
```
|
||||
sudo apt-get install python-gobject libnotify-bin python-gst-1.0
|
||||
|
|
11
main.py
11
main.py
|
@ -1,6 +1,5 @@
|
|||
#!/usr/bin/python3
|
||||
import notify2
|
||||
import gtk
|
||||
from time import sleep
|
||||
from playsound import playsound
|
||||
|
||||
|
@ -8,6 +7,7 @@ NAME = 'Eye Strain Reminder'
|
|||
MESSAGE = 'Friendly reminder to observe the 20-20-20 rule'
|
||||
TIMEOUT = 20
|
||||
MILLISECOND = 1000
|
||||
MINUTE = 60
|
||||
|
||||
def init():
|
||||
notify2.init(NAME)
|
||||
|
@ -15,10 +15,11 @@ def init():
|
|||
def uninit():
|
||||
notify2.uninit()
|
||||
|
||||
def wait():
|
||||
sleep(TIMEOUT*MINUTE)
|
||||
|
||||
def send_notification():
|
||||
notification = notify2.Notification(NAME, MESSAGE, "notification-device-eject")
|
||||
|
||||
#notification.set_icon_from_pixbuf(gtk.Label().render_icon(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_LARGE_TOOLBAR))
|
||||
notification.set_timeout(TIMEOUT * MILLISECOND)
|
||||
notification.set_urgency(notify2.URGENCY_LOW)
|
||||
notification.show()
|
||||
|
@ -29,5 +30,7 @@ def send_notification():
|
|||
|
||||
if __name__ == '__main__':
|
||||
init()
|
||||
send_notification()
|
||||
while 1:
|
||||
wait()
|
||||
send_notification()
|
||||
uninit()
|
Loading…
Reference in New Issue