migrated playerctl script to new bumblebee_status APIs

This commit is contained in:
smitajit 2020-06-06 14:39:50 +02:00
parent 4912fcc57b
commit 2dff5e2de7

View file

@ -9,25 +9,25 @@ contributed by `smitajit <https://github.com/smitajit>`_ - many thanks!
""" """
import bumblebee.util import core.module
import bumblebee.input import core.widget
import bumblebee.output import core.input
import bumblebee.engine import util.cli
class Module(bumblebee.engine.Module): class Module(core.module.Module):
def __init__(self, engine, config): def __init__(self,config , theme):
widgets = [ widgets = [
bumblebee.output.Widget(name="playerctl.prev"), core.widget.Widget(name="playerctl.prev"),
bumblebee.output.Widget(name="playerctl.main", full_text=self.description), core.widget.Widget(name="playerctl.main", full_text=self.description),
bumblebee.output.Widget(name="playerctl.next"), core.widget.Widget(name="playerctl.next"),
] ]
super(Module, self).__init__(engine, config, widgets) super(Module, self).__init__(config, theme , widgets)
engine.input.register_callback(widgets[0], button=bumblebee.input.LEFT_MOUSE, core.input.register(widgets[0], button=core.input.LEFT_MOUSE,
cmd="playerctl previous") cmd="playerctl previous")
engine.input.register_callback(widgets[1], button=bumblebee.input.LEFT_MOUSE, core.input.register(widgets[1], button=core.input.LEFT_MOUSE,
cmd="playerctl play-pause") cmd="playerctl play-pause")
engine.input.register_callback(widgets[2], button=bumblebee.input.LEFT_MOUSE, core.input.register(widgets[2], button=core.input.LEFT_MOUSE,
cmd="playerctl next") cmd="playerctl next")
self._status = None self._status = None
@ -36,7 +36,7 @@ class Module(bumblebee.engine.Module):
def description(self, widget): def description(self, widget):
return self._tags if self._tags else "..." return self._tags if self._tags else "..."
def update(self, widgets): def update(self):
self._load_song() self._load_song()
def state(self, widget): def state(self, widget):
@ -49,8 +49,8 @@ class Module(bumblebee.engine.Module):
def _load_song(self): def _load_song(self):
info = "" info = ""
try: try:
status = bumblebee.util.execute("playerctl status") status = util.cli.execute("playerctl status").lower()
info = bumblebee.util.execute("playerctl metadata xesam:title") info = util.cli.execute("playerctl metadata xesam:title")
except : except :
self._status = None self._status = None
self._tags = None self._tags = None