From 1a3217bb5fd27c8597c7eaab9681d68d9507fb9a Mon Sep 17 00:00:00 2001 From: Tobi-wan Kenobi Date: Sat, 10 Dec 2016 08:16:27 +0100 Subject: [PATCH] [modules/cmus] Add status callback Inform the theme about the current playback status (start, stop, repeat, shuffle). see #23 --- bumblebee/modules/cmus.py | 14 ++++++++++++++ themes/icons/awesome-fonts.json | 6 ++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/bumblebee/modules/cmus.py b/bumblebee/modules/cmus.py index f2dfea3..b58d47f 100644 --- a/bumblebee/modules/cmus.py +++ b/bumblebee/modules/cmus.py @@ -22,6 +22,9 @@ class Module(bumblebee.engine.Module): ] super(Module, self).__init__(engine, config, widgets) self._fmt = self.parameter("format", "{artist} - {title} {position}/{duration}") + self._status = None + self._shuffle = False + self._repeat = False def description(self): return string.Formatter().vformat(self._fmt, (), self._tags) @@ -29,6 +32,17 @@ class Module(bumblebee.engine.Module): def update(self, widgets): self._load_song() + def state(self, widget): + if widget.name == "cmus.shuffle": + return "shuffle-on" if self._shuffle else "shuffle-off" + if widget.name == "cmus.repeat": + return "repeat-on" if self._repeat else "repeat-off" + if widget.name == "cmus.prev": + return "prev" + if widget.name == "cmus.next": + return "next" + return self._status + def _load_song(self): info = "" try: diff --git a/themes/icons/awesome-fonts.json b/themes/icons/awesome-fonts.json index 3424710..c019337 100644 --- a/themes/icons/awesome-fonts.json +++ b/themes/icons/awesome-fonts.json @@ -13,8 +13,10 @@ "stopped": { "prefix": "" }, "prev": { "prefix": "" }, "next": { "prefix": "" }, - "shuffle": { "on": { "prefix": "" }, "off": { "prefix": "" } }, - "repeat": { "on": { "prefix": "" }, "off": { "prefix": "" } } + "shuffle-on": { "prefix": "" }, + "shuffle-off": { "prefix": "" }, + "repeat-on": { "prefix": "" }, + "repeat-off": { "prefix": "" } }, "pasink": { "muted": { "prefix": "" },