[modules] dunst: try to handle errors gracefully

Try to handle dunst pause/unpause errors "gracefully" (ignore them).

fixes #381
This commit is contained in:
Tobias Witek 2019-04-30 17:07:12 +02:00
parent 86c8dd5219
commit 94427ea20f

View file

@ -14,7 +14,10 @@ class Module(bumblebee.engine.Module):
) )
self._paused = False self._paused = False
# Make sure that dunst is currently not paused # Make sure that dunst is currently not paused
bumblebee.util.execute("killall -SIGUSR2 dunst") try:
bumblebee.util.execute("killall -SIGUSR2 dunst")
except:
pass
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE, engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE,
cmd=self.toggle_status cmd=self.toggle_status
) )
@ -22,10 +25,13 @@ class Module(bumblebee.engine.Module):
def toggle_status(self, event): def toggle_status(self, event):
self._paused = not self._paused self._paused = not self._paused
if self._paused: try:
bumblebee.util.execute("killall -SIGUSR1 dunst") if self._paused:
else: bumblebee.util.execute("killall -SIGUSR1 dunst")
bumblebee.util.execute("killall -SIGUSR2 dunst") else:
bumblebee.util.execute("killall -SIGUSR2 dunst")
except:
self._paused = not self._paused # toggling failed
def state(self, widget): def state(self, widget):
if self._paused: if self._paused: