2020-04-19 10:14:34 +02:00
|
|
|
# pylint: disable=C0111,R0903
|
|
|
|
|
|
|
|
"""Displays information about the current song in Google Play music player.
|
|
|
|
|
|
|
|
Requires the following executable:
|
|
|
|
* gpmdp-remote
|
|
|
|
"""
|
|
|
|
|
2020-04-19 10:24:06 +02:00
|
|
|
import core.module
|
|
|
|
import core.widget
|
|
|
|
import core.input
|
2020-04-19 10:14:34 +02:00
|
|
|
|
2020-04-19 10:24:06 +02:00
|
|
|
import util.cli
|
|
|
|
|
2020-05-03 11:15:52 +02:00
|
|
|
|
2020-04-19 10:24:06 +02:00
|
|
|
class Module(core.module.Module):
|
2020-04-26 16:39:24 +02:00
|
|
|
def __init__(self, config, theme):
|
2020-04-19 10:14:34 +02:00
|
|
|
widgets = [
|
2020-05-03 11:15:52 +02:00
|
|
|
core.widget.Widget(name="gpmdp.prev"),
|
|
|
|
core.widget.Widget(name="gpmdp.main", full_text=self.description),
|
|
|
|
core.widget.Widget(name="gpmdp.next"),
|
2020-04-19 10:14:34 +02:00
|
|
|
]
|
2020-04-26 16:39:24 +02:00
|
|
|
super().__init__(config, theme, widgets)
|
2020-04-19 10:14:34 +02:00
|
|
|
|
2020-05-03 11:15:52 +02:00
|
|
|
core.input.register(
|
|
|
|
widgets[0], button=core.input.LEFT_MOUSE, cmd="playerctl previous"
|
|
|
|
)
|
|
|
|
core.input.register(
|
|
|
|
widgets[1], button=core.input.LEFT_MOUSE, cmd="playerctl play-pause"
|
|
|
|
)
|
|
|
|
core.input.register(
|
|
|
|
widgets[2], button=core.input.LEFT_MOUSE, cmd="playerctl next"
|
|
|
|
)
|
2020-04-19 10:14:34 +02:00
|
|
|
|
2020-04-19 10:24:06 +02:00
|
|
|
self.__status = None
|
|
|
|
self.__tags = None
|
2020-04-19 10:14:34 +02:00
|
|
|
|
|
|
|
def description(self, widget):
|
2020-05-03 11:15:52 +02:00
|
|
|
return self.__tags if self.__tags else "n/a"
|
2020-04-19 10:14:34 +02:00
|
|
|
|
2020-04-19 10:24:06 +02:00
|
|
|
def update(self):
|
|
|
|
self.__load_song()
|
2020-04-19 10:14:34 +02:00
|
|
|
|
|
|
|
def state(self, widget):
|
2020-05-03 11:15:52 +02:00
|
|
|
if widget.name == "gpmdp.prev":
|
|
|
|
return "prev"
|
|
|
|
if widget.name == "gpmdp.next":
|
|
|
|
return "next"
|
2020-04-19 10:24:06 +02:00
|
|
|
return self.__status
|
|
|
|
|
|
|
|
def __load_song(self):
|
2020-05-03 11:15:52 +02:00
|
|
|
info = util.cli.execute("gpmdp-remote current", ignore_errors=True)
|
|
|
|
status = util.cli.execute("gpmdp-remote status", ignore_errors=True)
|
|
|
|
self.__status = status.split("\n")[0].lower()
|
|
|
|
self.__tags = info.split("\n")[0]
|
|
|
|
|
2020-04-19 10:14:34 +02:00
|
|
|
|
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|