Mute toggling

This commit is contained in:
Abhorrent_Anger 2019-10-28 15:09:55 +02:00 committed by Mārtiņš Kurmis
parent 9b2496e8a0
commit adccf133e1
2 changed files with 15 additions and 8 deletions

View File

@ -7,7 +7,7 @@ First, you might need these packages:
sudo apt-get install python-gobject libnotify-bin python-gst-1.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: Second, just install the tool and required [Python modules](setup.py) by cloning the repository and running:
``` ```
cd EyeStrainReminder cd EyeStrainReminder
pip install . --user pip install . --user

View File

@ -14,26 +14,33 @@ MILLISECOND = 1000
MINUTE = 60 MINUTE = 60
DIR = os.path.dirname(os.path.abspath(__file__)) DIR = os.path.dirname(os.path.abspath(__file__))
icon = None
mute = False mute = False
disable_notifications = False
def set_mute(): def toggle_mute():
global mute global mute
mute = True mute = True if not mute else False
update_menu()
def generate_menu_items(): def generate_menu_items():
menu_items = [] menu_items = []
if not mute: if not mute:
menu_items.append(item('Mute', set_mute)) menu_items.append(item('Mute', toggle_mute))
else: else:
menu_items.append(item('Unmute', set_mute)) menu_items.append(item('Unmute', toggle_mute))
return menu_items return menu_items
def update_menu():
global icon
icon.menu = generate_menu_items()
icon.update_menu()
def init(): def init():
global icon
image = Image.open(f"{DIR}/files/eye_light.png") image = Image.open(f"{DIR}/files/eye_light.png")
icon = pystray.Icon(NAME, image, NAME, generate_menu_items()) icon = pystray.Icon(NAME, image, NAME, generate_menu_items())
icon.run() icon.run()
print("Initializing EyeStrainReminder...") print("Initializing EyeStrainReminder...")
notify2.init(NAME) notify2.init(NAME)