[modules/mocp] Update to latest API

This commit is contained in:
tobi-wan-kenobi 2020-04-19 14:37:16 +02:00
parent b942c617c5
commit 0ea37b7b62

View file

@ -23,38 +23,32 @@ Parameters:
%r Sample rate %r Sample rate
""" """
import bumblebee.util import core.module
import bumblebee.input import core.widget
import bumblebee.output import core.input
import bumblebee.engine
from bumblebee.output import scrollable import util.cli
class Module(bumblebee.engine.Module): class Module(core.module.Module):
def __init__(self, engine, config): def __init__(self, config):
super(Module, self).__init__(engine, config, super().__init__(config, core.widget.Widget(self.description))
bumblebee.output.Widget(name='mocp.main', full_text=self.description)
)
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE, core.input.register(self, button=core.input.LEFT_MOUSE, cmd='mocp -G')
cmd='mocp -G') core.input.register(self, button=core.input.RIGHT_MOUSE, cmd='mocp -t shuffle')
engine.input.register_callback(self, button=bumblebee.input.RIGHT_MOUSE, self.__format = self.parameter('format', '%state %artist - %song | %ct/%tt')
cmd='mocp -t shuffle') self.__running = False
self._format = self.parameter('format', '%state %artist - %song | %ct/%tt')
self._running = 0
#@scrollable
def description(self, widget): def description(self, widget):
return self._info if self._running == 1 else 'Music On Console Player' return self.__info if self.__running == True else 'Music On Console Player'
def update(self, widgets): def update(self):
self._load_song() self.__load_song()
def _load_song(self): def __load_song(self):
try: try:
self._info = bumblebee.util.execute('mocp -Q '' + self._format + """ ).strip() self.__info = util.cli.execute("mocp -Q '{}'".format(self.__format)).strip()
self._running = 1 self.__running = True
except RuntimeError: except RuntimeError:
self._running = 0 self.__running = False
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4