From 0ea37b7b623e640900acb13dde17c17b3be98205 Mon Sep 17 00:00:00 2001 From: tobi-wan-kenobi Date: Sun, 19 Apr 2020 14:37:16 +0200 Subject: [PATCH] [modules/mocp] Update to latest API --- modules/contrib/mocp.py | 42 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/modules/contrib/mocp.py b/modules/contrib/mocp.py index b134105..533d641 100644 --- a/modules/contrib/mocp.py +++ b/modules/contrib/mocp.py @@ -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