Basic menu
This commit is contained in:
parent
5fd4a1ebad
commit
9b2496e8a0
|
@ -4,7 +4,7 @@ A small background tool to remind the user of the "20-20-20" rule. Uses system n
|
|||
|
||||
First, you might need these packages:
|
||||
```
|
||||
sudo apt-get install python-gobject libnotify-bin python-gst-1.0 python-wxgtk3.0
|
||||
sudo apt-get install python-gobject libnotify-bin python-gst-1.0
|
||||
```
|
||||
|
||||
Second, just install the tool and required [Python modules](src/branch/master/setup.py) via:
|
||||
|
|
|
@ -3,6 +3,9 @@ import notify2
|
|||
from time import sleep
|
||||
from playsound import playsound
|
||||
import os
|
||||
from pystray import MenuItem as item
|
||||
import pystray
|
||||
from PIL import Image
|
||||
|
||||
NAME = 'Eye Strain Reminder'
|
||||
MESSAGE = 'Friendly reminder to observe the 20-20-20 rule'
|
||||
|
@ -11,7 +14,26 @@ MILLISECOND = 1000
|
|||
MINUTE = 60
|
||||
DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
mute = False
|
||||
|
||||
def set_mute():
|
||||
global mute
|
||||
mute = True
|
||||
|
||||
def generate_menu_items():
|
||||
menu_items = []
|
||||
if not mute:
|
||||
menu_items.append(item('Mute', set_mute))
|
||||
else:
|
||||
menu_items.append(item('Unmute', set_mute))
|
||||
return menu_items
|
||||
|
||||
def init():
|
||||
image = Image.open(f"{DIR}/files/eye_light.png")
|
||||
icon = pystray.Icon(NAME, image, NAME, generate_menu_items())
|
||||
icon.run()
|
||||
|
||||
|
||||
print("Initializing EyeStrainReminder...")
|
||||
notify2.init(NAME)
|
||||
|
||||
|
@ -19,7 +41,12 @@ def uninit():
|
|||
notify2.uninit()
|
||||
|
||||
def wait():
|
||||
sleep(TIMEOUT*MINUTE)
|
||||
#sleep(TIMEOUT*MINUTE)
|
||||
pass
|
||||
|
||||
def play_sound():
|
||||
if not mute:
|
||||
playsound(f"{DIR}/files/default.wav")
|
||||
|
||||
def send_notification():
|
||||
print(MESSAGE)
|
||||
|
@ -27,11 +54,10 @@ def send_notification():
|
|||
notification.set_timeout(TIMEOUT * MILLISECOND)
|
||||
notification.set_urgency(notify2.URGENCY_LOW)
|
||||
notification.show()
|
||||
|
||||
playsound(f"{DIR}/files/default.wav")
|
||||
play_sound()
|
||||
sleep(TIMEOUT)
|
||||
notification.close()
|
||||
playsound(f"{DIR}/files/default.wav")
|
||||
play_sound()
|
||||
|
||||
def main():
|
||||
init()
|
||||
|
|
Loading…
Reference in New Issue