Mute toggling
This commit is contained in:
parent
9b2496e8a0
commit
adccf133e1
|
@ -7,7 +7,7 @@ First, you might need these packages:
|
|||
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
|
||||
pip install . --user
|
||||
|
|
|
@ -14,26 +14,33 @@ MILLISECOND = 1000
|
|||
MINUTE = 60
|
||||
DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
icon = None
|
||||
mute = False
|
||||
disable_notifications = False
|
||||
|
||||
def set_mute():
|
||||
def toggle_mute():
|
||||
global mute
|
||||
mute = True
|
||||
mute = True if not mute else False
|
||||
update_menu()
|
||||
|
||||
def generate_menu_items():
|
||||
menu_items = []
|
||||
if not mute:
|
||||
menu_items.append(item('Mute', set_mute))
|
||||
menu_items.append(item('Mute', toggle_mute))
|
||||
else:
|
||||
menu_items.append(item('Unmute', set_mute))
|
||||
menu_items.append(item('Unmute', toggle_mute))
|
||||
return menu_items
|
||||
|
||||
def update_menu():
|
||||
global icon
|
||||
icon.menu = generate_menu_items()
|
||||
icon.update_menu()
|
||||
|
||||
def init():
|
||||
global icon
|
||||
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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue