diff --git a/bumblebee_status/modules/contrib/playerctl.py b/bumblebee_status/modules/contrib/playerctl.py new file mode 100755 index 0000000..b145500 --- /dev/null +++ b/bumblebee_status/modules/contrib/playerctl.py @@ -0,0 +1,61 @@ +# pylint: disable=C0111,R0903 + +"""Displays information about the current song in vlc, audacious, bmp, xmms2, spotify and others + +Requires the following executable: + * playerctl + +contributed by `smitajit `_ - many thanks! + +""" + +import core.module +import core.widget +import core.input +import util.cli + +class Module(core.module.Module): + def __init__(self,config , theme): + widgets = [ + core.widget.Widget(name="playerctl.prev"), + core.widget.Widget(name="playerctl.main", full_text=self.description), + core.widget.Widget(name="playerctl.next"), + ] + super(Module, self).__init__(config, theme , widgets) + + core.input.register(widgets[0], button=core.input.LEFT_MOUSE, + cmd="playerctl previous") + core.input.register(widgets[1], button=core.input.LEFT_MOUSE, + cmd="playerctl play-pause") + core.input.register(widgets[2], button=core.input.LEFT_MOUSE, + cmd="playerctl next") + + self._status = None + self._tags = None + + def description(self, widget): + return self._tags if self._tags else "..." + + def update(self): + self._load_song() + + def state(self, widget): + if widget.name == "playerctl.prev": + return "prev" + if widget.name == "playerctl.next": + return "next" + return self._status + + def _load_song(self): + info = "" + try: + status = util.cli.execute("playerctl status").lower() + info = util.cli.execute("playerctl metadata xesam:title") + except : + self._status = None + self._tags = None + return + self._status = status.split("\n")[0].lower() + self._tags = info.split("\n")[0][:20] + +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 diff --git a/docs/modules.rst b/docs/modules.rst index a99c452..3afc95d 100644 --- a/docs/modules.rst +++ b/docs/modules.rst @@ -149,6 +149,18 @@ Parameters: .. image:: ../screenshots/ping.png +playerctl +~~~~~~~~~~ +Displays information about the current song in vlc, audacious, bmp, xmms2, spotify and others + +Requires the following executable: + * playerctl + +contributed by `smitajit `_ - many thanks! + +.. image:: ../screenshots/playerctl.png + + pulseaudio ~~~~~~~~~~ diff --git a/screenshots/playerctl.png b/screenshots/playerctl.png new file mode 100644 index 0000000..588e745 Binary files /dev/null and b/screenshots/playerctl.png differ diff --git a/themes/icons/awesome-fonts.json b/themes/icons/awesome-fonts.json index e660c1d..5a5269c 100644 --- a/themes/icons/awesome-fonts.json +++ b/themes/icons/awesome-fonts.json @@ -65,6 +65,13 @@ "prev": { "prefix": "" }, "next": { "prefix": "" } }, + "playerctl": { + "playing": { "prefix": "" }, + "paused": { "prefix": "" }, + "stopped": { "prefix": "" }, + "prev": { "prefix": "" }, + "next": { "prefix": "" } + }, "pasink": { "muted": { "prefix": "" }, "unmuted": { "prefix": "" } diff --git a/themes/icons/ionicons.json b/themes/icons/ionicons.json index 4b90133..3e577bf 100644 --- a/themes/icons/ionicons.json +++ b/themes/icons/ionicons.json @@ -47,6 +47,13 @@ "prev": { "prefix": "\uf4ab" }, "next": { "prefix": "\uf4ad" } }, + "playerctl": { + "playing": { "prefix": "\uf488" }, + "paused": { "prefix": "\uf210" }, + "stopped": { "prefix": "\uf24f" }, + "prev": { "prefix": "\uf4ab" }, + "next": { "prefix": "\uf4ad" } + }, "pasink": { "muted": { "prefix": "\uf3b9" }, "unmuted": { "prefix": "\uf3ba" }