diff --git a/bumblebee/modules/dunst.py b/bumblebee/modules/dunst.py new file mode 100644 index 0000000..e2dbaa0 --- /dev/null +++ b/bumblebee/modules/dunst.py @@ -0,0 +1,33 @@ +#pylint: disable=C0111,R0903 + +"""Toggle dunst notifications.""" + +import bumblebee.input +import bumblebee.output +import bumblebee.engine + + +class Module(bumblebee.engine.Module): + def __init__(self, engine, config): + super(Module, self).__init__(engine, config, + bumblebee.output.Widget(full_text="") + ) + self._paused = False + # Make sure that dunst is currently not paused + bumblebee.util.execute("killall -SIGUSR2 dunst") + engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE, + cmd=self.toggle_status + ) + + def toggle_status(self, event): + self._paused = not self._paused + + if self._paused: + bumblebee.util.execute("killall -SIGUSR1 dunst") + else: + bumblebee.util.execute("killall -SIGUSR2 dunst") + + def state(self, widget): + if self._paused: + return ["muted", "warning"] + return ["unmuted"] diff --git a/themes/icons/ascii.json b/themes/icons/ascii.json index f0e3621..84a5890 100644 --- a/themes/icons/ascii.json +++ b/themes/icons/ascii.json @@ -125,4 +125,9 @@ "modified": { "prefix": "[m]" }, "deleted": { "prefix": "[d]" } } + "dunst": { + "muted": { "prefix": "dunst(muted)"}, + "unmuted": { "prefix": "dunst" } + } + } diff --git a/themes/icons/awesome-fonts.json b/themes/icons/awesome-fonts.json index c379354..5513466 100644 --- a/themes/icons/awesome-fonts.json +++ b/themes/icons/awesome-fonts.json @@ -188,5 +188,9 @@ "new": { "prefix": "" }, "modified": { "prefix": "" }, "deleted": { "prefix": "" } - } + }, + "dunst": { + "muted": { "prefix": ""}, + "unmuted": { "prefix": "" } + } } diff --git a/themes/icons/ionicons.json b/themes/icons/ionicons.json index ae1fa2e..6e64537 100644 --- a/themes/icons/ionicons.json +++ b/themes/icons/ionicons.json @@ -159,4 +159,9 @@ "taskwarrior": { "prefix": "\uf454" } + "dunst": { + "muted": { "prefix": "\uf39a"}, + "unmuted": { "prefix": "\uf39b" } + } + }