bumblebee-status/modules/contrib/dunst.py
tobi-wan-kenobi b66b13211e [modules/dunst] Fix toggling
At least Void Linux doesn't like kill -SIGUSR<N>

Also, added some debugging to inspect state changes for modules/widgets.

Also also, fix problem with min width, if no minwidth is set
2020-03-29 14:14:30 +02:00

35 lines
1,001 B
Python

#pylint: disable=C0111,R0903
'''Toggle dunst notifications.'''
import core.module
import core.widget
import core.input
import util.cli
class Module(core.module.Module):
def __init__(self, config=None):
super().__init__(config, core.widget.Widget(''))
self._paused = False
# Make sure that dunst is currently not paused
util.cli.execute('killall -s SIGUSR2 dunst', ignore_errors=True)
core.input.register(self, button=core.input.LEFT_MOUSE,
cmd=self.toggle_status
)
def toggle_status(self, event):
self._paused = not self._paused
try:
if self._paused:
util.cli.execute('killall -s SIGUSR1 dunst')
else:
util.cli.execute('killall -s SIGUSR2 dunst')
except:
self._paused = not self._paused # toggling failed
def state(self, widget):
if self._paused:
return ['muted', 'warning']
return ['unmuted']