[module] playerctl to displays information about the current song in vlc, audacious, bmp, xmms2, spotify and others
This commit is contained in:
parent
23d7222576
commit
4912fcc57b
5 changed files with 87 additions and 0 deletions
61
bumblebee_status/modules/contrib/playerctl.py
Executable file
61
bumblebee_status/modules/contrib/playerctl.py
Executable file
|
@ -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 <https://github.com/smitajit>`_ - many thanks!
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
import bumblebee.util
|
||||||
|
import bumblebee.input
|
||||||
|
import bumblebee.output
|
||||||
|
import bumblebee.engine
|
||||||
|
|
||||||
|
class Module(bumblebee.engine.Module):
|
||||||
|
def __init__(self, engine, config):
|
||||||
|
widgets = [
|
||||||
|
bumblebee.output.Widget(name="playerctl.prev"),
|
||||||
|
bumblebee.output.Widget(name="playerctl.main", full_text=self.description),
|
||||||
|
bumblebee.output.Widget(name="playerctl.next"),
|
||||||
|
]
|
||||||
|
super(Module, self).__init__(engine, config, widgets)
|
||||||
|
|
||||||
|
engine.input.register_callback(widgets[0], button=bumblebee.input.LEFT_MOUSE,
|
||||||
|
cmd="playerctl previous")
|
||||||
|
engine.input.register_callback(widgets[1], button=bumblebee.input.LEFT_MOUSE,
|
||||||
|
cmd="playerctl play-pause")
|
||||||
|
engine.input.register_callback(widgets[2], button=bumblebee.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, widgets):
|
||||||
|
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 = bumblebee.util.execute("playerctl status")
|
||||||
|
info = bumblebee.util.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
|
|
@ -149,6 +149,18 @@ Parameters:
|
||||||
|
|
||||||
.. image:: ../screenshots/ping.png
|
.. 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 <https://github.com/smitajit>`_ - many thanks!
|
||||||
|
|
||||||
|
.. image:: ../screenshots/playerctl.png
|
||||||
|
|
||||||
|
|
||||||
pulseaudio
|
pulseaudio
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
|
|
||||||
|
|
BIN
screenshots/playerctl.png
Normal file
BIN
screenshots/playerctl.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
|
@ -65,6 +65,13 @@
|
||||||
"prev": { "prefix": "" },
|
"prev": { "prefix": "" },
|
||||||
"next": { "prefix": "" }
|
"next": { "prefix": "" }
|
||||||
},
|
},
|
||||||
|
"playerctl": {
|
||||||
|
"playing": { "prefix": "" },
|
||||||
|
"paused": { "prefix": "" },
|
||||||
|
"stopped": { "prefix": "" },
|
||||||
|
"prev": { "prefix": "" },
|
||||||
|
"next": { "prefix": "" }
|
||||||
|
},
|
||||||
"pasink": {
|
"pasink": {
|
||||||
"muted": { "prefix": "" },
|
"muted": { "prefix": "" },
|
||||||
"unmuted": { "prefix": "" }
|
"unmuted": { "prefix": "" }
|
||||||
|
|
|
@ -47,6 +47,13 @@
|
||||||
"prev": { "prefix": "\uf4ab" },
|
"prev": { "prefix": "\uf4ab" },
|
||||||
"next": { "prefix": "\uf4ad" }
|
"next": { "prefix": "\uf4ad" }
|
||||||
},
|
},
|
||||||
|
"playerctl": {
|
||||||
|
"playing": { "prefix": "\uf488" },
|
||||||
|
"paused": { "prefix": "\uf210" },
|
||||||
|
"stopped": { "prefix": "\uf24f" },
|
||||||
|
"prev": { "prefix": "\uf4ab" },
|
||||||
|
"next": { "prefix": "\uf4ad" }
|
||||||
|
},
|
||||||
"pasink": {
|
"pasink": {
|
||||||
"muted": { "prefix": "\uf3b9" },
|
"muted": { "prefix": "\uf3b9" },
|
||||||
"unmuted": { "prefix": "\uf3ba" }
|
"unmuted": { "prefix": "\uf3ba" }
|
||||||
|
|
Loading…
Reference in a new issue