[modules/gpmdp] Update to latest API
This commit is contained in:
parent
10a1bc18ad
commit
c591505977
1 changed files with 27 additions and 30 deletions
|
@ -6,51 +6,48 @@ Requires the following executable:
|
||||||
* gpmdp-remote
|
* gpmdp-remote
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import bumblebee.util
|
import core.module
|
||||||
import bumblebee.input
|
import core.widget
|
||||||
import bumblebee.output
|
import core.input
|
||||||
import bumblebee.engine
|
|
||||||
|
|
||||||
class Module(bumblebee.engine.Module):
|
import util.cli
|
||||||
def __init__(self, engine, config):
|
|
||||||
|
class Module(core.module.Module):
|
||||||
|
def __init__(self, config):
|
||||||
widgets = [
|
widgets = [
|
||||||
bumblebee.output.Widget(name='gpmdp.prev'),
|
core.widget.Widget(name='gpmdp.prev'),
|
||||||
bumblebee.output.Widget(name='gpmdp.main', full_text=self.description),
|
core.widget.Widget(name='gpmdp.main', full_text=self.description),
|
||||||
bumblebee.output.Widget(name='gpmdp.next'),
|
core.widget.Widget(name='gpmdp.next'),
|
||||||
]
|
]
|
||||||
super(Module, self).__init__(engine, config, widgets)
|
super().__init__(config, 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
|
||||||
self._tags = None
|
self.__tags = None
|
||||||
|
|
||||||
def description(self, widget):
|
def description(self, widget):
|
||||||
return self._tags if self._tags else 'n/a'
|
return self.__tags if self.__tags else 'n/a'
|
||||||
|
|
||||||
def update(self, widgets):
|
def update(self):
|
||||||
self._load_song()
|
self.__load_song()
|
||||||
|
|
||||||
def state(self, widget):
|
def state(self, widget):
|
||||||
if widget.name == 'gpmdp.prev':
|
if widget.name() == 'gpmdp.prev':
|
||||||
return 'prev'
|
return 'prev'
|
||||||
if widget.name == 'gpmdp.next':
|
if widget.name() == 'gpmdp.next':
|
||||||
return 'next'
|
return 'next'
|
||||||
return self._status
|
return self.__status
|
||||||
|
|
||||||
def _load_song(self):
|
def __load_song(self):
|
||||||
info = ''
|
info = util.cli.execute('gpmdp-remote current', ignore_errors=True)
|
||||||
try:
|
status = util.cli.execute('gpmdp-remote status', ignore_errors=True)
|
||||||
info = bumblebee.util.execute('gpmdp-remote current')
|
self.__status = status.split('\n')[0].lower()
|
||||||
status = bumblebee.util.execute('gpmdp-remote status')
|
self.__tags = info.split('\n')[0]
|
||||||
except RuntimeError:
|
|
||||||
pass
|
|
||||||
self._status = status.split('\n')[0].lower()
|
|
||||||
self._tags = info.split('\n')[0]
|
|
||||||
|
|
||||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||||
|
|
Loading…
Reference in a new issue