[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
"""
import bumblebee.util
import bumblebee.input
import bumblebee.output
import bumblebee.engine
import core.module
import core.widget
import core.input
from bumblebee.output import scrollable
import util.cli
class Module(bumblebee.engine.Module):
def __init__(self, engine, config):
super(Module, self).__init__(engine, config,
bumblebee.output.Widget(name='mocp.main', full_text=self.description)
)
class Module(core.module.Module):
def __init__(self, config):
super().__init__(config, core.widget.Widget(self.description))
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE,
cmd='mocp -G')
engine.input.register_callback(self, button=bumblebee.input.RIGHT_MOUSE,
cmd='mocp -t shuffle')
self._format = self.parameter('format', '%state %artist - %song | %ct/%tt')
self._running = 0
core.input.register(self, button=core.input.LEFT_MOUSE, cmd='mocp -G')
core.input.register(self, button=core.input.RIGHT_MOUSE, cmd='mocp -t shuffle')
self.__format = self.parameter('format', '%state %artist - %song | %ct/%tt')
self.__running = False
#@scrollable
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):
self._load_song()
def update(self):
self.__load_song()
def _load_song(self):
def __load_song(self):
try:
self._info = bumblebee.util.execute('mocp -Q '' + self._format + """ ).strip()
self._running = 1
self.__info = util.cli.execute("mocp -Q '{}'".format(self.__format)).strip()
self.__running = True
except RuntimeError:
self._running = 0
self.__running = False
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4