From bba5143434d43fdabdb56d3b62d40d0bf6d8ce45 Mon Sep 17 00:00:00 2001 From: Abhorrent_Anger Date: Tue, 22 Oct 2019 13:55:16 +0300 Subject: [PATCH] Functional sleep loop --- README.md | 2 +- main.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 215b5af..1347702 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/main.py b/main.py index 6eece4d..69a3587 100755 --- a/main.py +++ b/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() \ No newline at end of file