From 0f1725982ac5e307d17078c9afb451673d74aad7 Mon Sep 17 00:00:00 2001 From: Pavle Portic Date: Mon, 2 Jan 2017 21:44:53 +0100 Subject: [PATCH] [modules/gpmdp] Add Google play music desktop player support --- bumblebee/modules/gpmdp.py | 56 +++++++++++++++++++++++++++++++++ themes/icons/awesome-fonts.json | 7 +++++ 2 files changed, 63 insertions(+) create mode 100644 bumblebee/modules/gpmdp.py diff --git a/bumblebee/modules/gpmdp.py b/bumblebee/modules/gpmdp.py new file mode 100644 index 0000000..af96e9b --- /dev/null +++ b/bumblebee/modules/gpmdp.py @@ -0,0 +1,56 @@ +# pylint: disable=C0111,R0903 + +"""Displays information about the current song in Google Play music player. + +""" + +import string + +import bumblebee.util +import bumblebee.input +import bumblebee.output +import bumblebee.engine + +class Module(bumblebee.engine.Module): + def __init__(self, engine, config): + widgets = [ + bumblebee.output.Widget(name="gpmdp.prev"), + bumblebee.output.Widget(name="gpmdp.main", full_text=self.description), + bumblebee.output.Widget(name="gpmdp.next"), + ] + super(Module, self).__init__(engine, config, widgets) + + engine.input.register_callback(widgets[0], button=bumblebee.input.LEFT_MOUSE, + cmd="playerctl previous") + engine.input.register_callback(widgets[1], button=bumblebee.input.LEFT_MOUSE, + cmd="playerctl play-pause") + engine.input.register_callback(widgets[2], button=bumblebee.input.LEFT_MOUSE, + cmd="playerctl next") + + self._status = None + self._tags = None + + def description(self, widget): + return self._tags + + def update(self, widgets): + self._load_song() + + def state(self, widget): + if widget.name == "gpmdp.prev": + return "prev" + if widget.name == "gpmdp.next": + return "next" + return self._status + + def _load_song(self): + info = "" + try: + info = bumblebee.util.execute("gpmdp-remote current") + status = bumblebee.util.execute("gpmdp-remote status") + except RuntimeError: + pass + self._status = status.split("\n")[0].lower() + self._tags = info.split("\n")[0] + +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 diff --git a/themes/icons/awesome-fonts.json b/themes/icons/awesome-fonts.json index 664551f..a8eda48 100644 --- a/themes/icons/awesome-fonts.json +++ b/themes/icons/awesome-fonts.json @@ -23,6 +23,13 @@ "repeat-on": { "prefix": "" }, "repeat-off": { "prefix": "" } }, + "gpmdp": { + "playing": { "prefix": "" }, + "paused": { "prefix": "" }, + "stopped": { "prefix": "" }, + "prev": { "prefix": "" }, + "next": { "prefix": "" } + }, "pasink": { "muted": { "prefix": "" }, "unmuted": { "prefix": "" }