From eb0035fdd04c2b72063c88e3a8ee83e1de047368 Mon Sep 17 00:00:00 2001 From: Rafael Cavalcanti Date: Mon, 24 Jul 2017 11:19:39 -0300 Subject: [PATCH 1/3] Add click events to Spotify module --- bumblebee/modules/spotify.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bumblebee/modules/spotify.py b/bumblebee/modules/spotify.py index da7d032..22ddc6a 100644 --- a/bumblebee/modules/spotify.py +++ b/bumblebee/modules/spotify.py @@ -25,6 +25,15 @@ class Module(bumblebee.engine.Module): ) self._song = "" + cmd="dbus-send --session --type=method_call --dest=org.mpris.MediaPlayer2.spotify \ + /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player." + engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE, + cmd=cmd + "Previous") + engine.input.register_callback(self, button=bumblebee.input.RIGHT_MOUSE, + cmd=cmd + "Next") + engine.input.register_callback(self, button=bumblebee.input.MIDDLE_MOUSE, + cmd=cmd + "PlayPause") + def spotify(self, widget): return str(self._song) From 78adbc0b4a2eac7804992d01ef417ace5e6bbec5 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Tue, 25 Jul 2017 06:52:28 +0200 Subject: [PATCH 2/3] [module/github] Add pagination support The GitHub API returns 50 items per page. --- bumblebee/modules/github.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/bumblebee/modules/github.py b/bumblebee/modules/github.py index 6c97650..bbd3bd8 100644 --- a/bumblebee/modules/github.py +++ b/bumblebee/modules/github.py @@ -29,6 +29,8 @@ class Module(bumblebee.engine.Module): self._count = 0 self._interval = int(self.parameter("interval", "5")) self._nextcheck = 0 + self._requests = requests.Session() + self._requests.headers.update({"Authorization":"token {}".format(self.parameter("token", ""))}) engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE, cmd="x-www-browser https://github.com/notifications") immediate_update = functools.partial(self.update, immediate=True) @@ -41,15 +43,19 @@ class Module(bumblebee.engine.Module): def update(self, _, immediate=False): if immediate or self._nextcheck < int(time.time()): self._nextcheck = int(time.time()) + self._interval * 60 - token = self.parameter("token", "") - if not token: - self._count = "n/a" - return - try: - notifications = requests.get("https://api.github.com/notifications", headers={"Authorization":"token {}".format(token)}).json() - self._count = len(filter(lambda notification: notification.get("unread", False), notifications)) + self._count = 0 + url = "https://api.github.com/notifications" + while True: + notifications = self._requests.get(url) + self._count += len(filter(lambda notification: notification.get("unread", False), notifications.json())) + next_link = notifications.links.get('next') + if next_link is not None: + url = next_link.get('url') + else: + break + except Exception: self._count = "n/a" From 216ef815c7f236bef8c8e646e43a547ee5ea2528 Mon Sep 17 00:00:00 2001 From: Vidyu Krastev Date: Thu, 27 Jul 2017 16:01:56 +0200 Subject: [PATCH 3/3] Locale for datetime module --- bumblebee/modules/datetime.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bumblebee/modules/datetime.py b/bumblebee/modules/datetime.py index 4141a53..e1b9236 100644 --- a/bumblebee/modules/datetime.py +++ b/bumblebee/modules/datetime.py @@ -10,8 +10,11 @@ Parameters: from __future__ import absolute_import import datetime +import locale import bumblebee.engine +locale.setlocale(locale.LC_TIME, locale.getdefaultlocale()) + ALIASES = [ "date", "time" ] def default_format(module):