Functional sleep loop
This commit is contained in:
parent
12dc22372d
commit
bba5143434
|
@ -1,6 +1,6 @@
|
||||||
# EyeStrainReminder
|
# 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
|
sudo apt-get install python-gobject libnotify-bin python-gst-1.0
|
||||||
|
|
9
main.py
9
main.py
|
@ -1,6 +1,5 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
import notify2
|
import notify2
|
||||||
import gtk
|
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from playsound import playsound
|
from playsound import playsound
|
||||||
|
|
||||||
|
@ -8,6 +7,7 @@ NAME = 'Eye Strain Reminder'
|
||||||
MESSAGE = 'Friendly reminder to observe the 20-20-20 rule'
|
MESSAGE = 'Friendly reminder to observe the 20-20-20 rule'
|
||||||
TIMEOUT = 20
|
TIMEOUT = 20
|
||||||
MILLISECOND = 1000
|
MILLISECOND = 1000
|
||||||
|
MINUTE = 60
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
notify2.init(NAME)
|
notify2.init(NAME)
|
||||||
|
@ -15,10 +15,11 @@ def init():
|
||||||
def uninit():
|
def uninit():
|
||||||
notify2.uninit()
|
notify2.uninit()
|
||||||
|
|
||||||
|
def wait():
|
||||||
|
sleep(TIMEOUT*MINUTE)
|
||||||
|
|
||||||
def send_notification():
|
def send_notification():
|
||||||
notification = notify2.Notification(NAME, MESSAGE, "notification-device-eject")
|
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_timeout(TIMEOUT * MILLISECOND)
|
||||||
notification.set_urgency(notify2.URGENCY_LOW)
|
notification.set_urgency(notify2.URGENCY_LOW)
|
||||||
notification.show()
|
notification.show()
|
||||||
|
@ -29,5 +30,7 @@ def send_notification():
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
init()
|
init()
|
||||||
|
while 1:
|
||||||
|
wait()
|
||||||
send_notification()
|
send_notification()
|
||||||
uninit()
|
uninit()
|
Loading…
Reference in New Issue