[modules/twmn] Update to latest API

This commit is contained in:
tobi-wan-kenobi 2020-04-13 13:30:35 +02:00
parent 7edaadffdf
commit 95d046d5e8

View file

@ -2,38 +2,37 @@
"""Toggle twmn notifications.""" """Toggle twmn notifications."""
import bumblebee.input import core.module
import bumblebee.output import core.widget
import bumblebee.engine import core.input
import core.decorators
import util.cli
class Module(bumblebee.engine.Module): class Module(core.module.Module):
def __init__(self, engine, config): @core.decorators.every(minutes=60)
super(Module, self).__init__(engine, config, def __init__(self, config):
bumblebee.output.Widget(full_text="") super().__init__(config, core.widget.Widget(''))
)
self._paused = False self.__paused = False
# Make sure that twmn is currently not paused # Make sure that twmn is currently not paused
try: util.cli.execute('killall -SIGUSR2 twmnd', ignore_errors=True)
bumblebee.util.execute("killall -SIGUSR2 twmnd") core.input.register(self, button=core.input.LEFT_MOUSE, cmd=self.toggle_status)
except:
pass
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE,
cmd=self.toggle_status
)
def toggle_status(self, event): def toggle_status(self, event):
self._paused = not self._paused self.__paused = not self.__paused
try: try:
if self._paused: if self.__paused:
bumblebee.util.execute("systemctl --user start twmnd") util.cli.execute('systemctl --user start twmnd')
else: else:
bumblebee.util.execute("systemctl --user stop twmnd") util.cli.execute('systemctl --user stop twmnd')
except: except:
self._paused = not self._paused # toggling failed self.__paused = not self.__paused # toggling failed
def state(self, widget): def state(self, widget):
if self._paused: if self.__paused:
return ["muted"] return ['muted']
return ["unmuted"] return ['unmuted']
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4