From c75518e8f77c1034868a60093dce6c940ac27d61 Mon Sep 17 00:00:00 2001 From: Camilo Celis Guzman Date: Sat, 11 Nov 2017 15:22:12 +0900 Subject: [PATCH 1/7] [modules] added new shortcut module This modules makes it very easy to create shortcuts as widgets, for which the user can define the command to be executed when left clicking on it. It supports single or multiple shortcuts --- bumblebee/modules/shortcut.py | 70 +++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 bumblebee/modules/shortcut.py diff --git a/bumblebee/modules/shortcut.py b/bumblebee/modules/shortcut.py new file mode 100644 index 0000000..2ec6ab3 --- /dev/null +++ b/bumblebee/modules/shortcut.py @@ -0,0 +1,70 @@ +# pylint: disable=C0112,R0903 + +"""Shows a widget per user-defined shortcut and allows to define the behaviour +when clicking on it. + +For more than one shortcut, the commands and labels are strings separated by +a demiliter (; semicolon by default). + +For example in order to create two shortcuts labeled A and B with commands +cmdA and cmdB you could do: + + ./bumblebee-status -m shortcut -p shortcut.cmd="ls;ps" shortcut.label="A;B" + +Parameters: + * shortcut.cmds : List of commands to execute + * shortcut.labels: List of widgets' labels (text) + * shortcut.delim : Commands and labels delimiter (; semicolon by default) +""" + +import logging +import bumblebee.engine +import bumblebee.output +import bumblebee.input + +LINK = "https://github.com/tobi-wan-kenobi/bumblebee-status/wiki" +LABEL = "Click me" + +class Module(bumblebee.engine.Module): + """ Shortcut module.""" + + def __init__(self, engine, config): + widgets = [] + self._engine = engine + super(Module, self).__init__(engine, config, widgets) + + self._labels = self.parameter("labels", "{}".format(LABEL)) + self._cmds = self.parameter("cmds", "firefox {}".format(LINK)) + self._delim = self.parameter("delim", ";") + + self.update_widgets(widgets) + + def update_widgets(self, widgets): + """ Creates a set of widget per user define shortcut.""" + + cmds = self._cmds.split(self._delim) + labels = self._labels.split(self._delim) + + # to be on the safe side create as many widgets as there are data (cmds or labels) + num_shortcuts = min(len(cmds), len(labels)) + + # report possible problem as a warning + if (len(cmds) is not len(labels)): + logging.warning("shortcut: the number of commands does not match "\ + "the number of provided labels.") + logging.warning("cmds : %s, labels : %s", cmds, labels) + + for idx in range(0, num_shortcuts): + cmd = cmds[idx] + label = labels[idx] + + widget = bumblebee.output.Widget(full_text=label) + self._engine.input.register_callback(widget, button=bumblebee.input.LEFT_MOUSE, cmd=cmd) + + widgets.append(widget) + + def update(self, widgets): + if len(widgets) <= 0: + self.update_widgets(widgets) + +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 From 6b61d43648dd702f991626319eb4be04201f2d6d Mon Sep 17 00:00:00 2001 From: "Christian F. Coors" Date: Mon, 13 Nov 2017 15:02:57 +0100 Subject: [PATCH 2/7] Add uptime module --- bumblebee/modules/uptime.py | 26 ++++++++++++++++++++++++++ themes/icons/ascii.json | 3 +++ themes/icons/awesome-fonts.json | 3 ++- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 bumblebee/modules/uptime.py diff --git a/bumblebee/modules/uptime.py b/bumblebee/modules/uptime.py new file mode 100644 index 0000000..e7e68c9 --- /dev/null +++ b/bumblebee/modules/uptime.py @@ -0,0 +1,26 @@ +# pylint: disable=C0111,R0903 + +"""Displays the system uptime.""" + +import bumblebee.input +import bumblebee.output +import bumblebee.engine + +from datetime import timedelta + +class Module(bumblebee.engine.Module): + def __init__(self, engine, config): + super(Module, self).__init__(engine, config, + bumblebee.output.Widget(full_text=self.output) + ) + self._uptime = "" + + def output(self, _): + return "{}".format(self._uptime) + + def update(self, widgets): + with open('/proc/uptime', 'r') as f: + uptime_seconds = int(float(f.readline().split()[0])) + self._uptime = timedelta(seconds = uptime_seconds) + +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 diff --git a/themes/icons/ascii.json b/themes/icons/ascii.json index ca7be0e..347fcfd 100644 --- a/themes/icons/ascii.json +++ b/themes/icons/ascii.json @@ -86,5 +86,8 @@ }, "spotify": { "prefix": "" + }, + "uptime": { + "prefix": "uptime" } } diff --git a/themes/icons/awesome-fonts.json b/themes/icons/awesome-fonts.json index 4628828..f8bd8cc 100644 --- a/themes/icons/awesome-fonts.json +++ b/themes/icons/awesome-fonts.json @@ -16,7 +16,8 @@ "layout": { "prefix": "" }, "layout-xkb": { "prefix": "" }, "todo": { "empty": {"prefix": "" }, - "items": {"prefix": "" } + "items": {"prefix": "" }, + "uptime": {"prefix": "" } }, "cmus": { From 4bc96987db391f6ea179eb15e142c9e0e753cfae Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Mon, 13 Nov 2017 18:54:54 +0100 Subject: [PATCH 3/7] [modules/datetime] Rename datetime to date-time Finally fix the datetime import errors by renaming the bumblebee datetime module (*bad* idea from the start). Apologies to everyone for whom it now breaks. --- bumblebee/modules/{datetime.py => date-time.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename bumblebee/modules/{datetime.py => date-time.py} (100%) diff --git a/bumblebee/modules/datetime.py b/bumblebee/modules/date-time.py similarity index 100% rename from bumblebee/modules/datetime.py rename to bumblebee/modules/date-time.py From 4504f6fff39524087de832eae14377247a7bb749 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Mon, 13 Nov 2017 18:57:19 +0100 Subject: [PATCH 4/7] [screenshots] Add new modules --- screenshots/shortcut.png | Bin 0 -> 1110 bytes screenshots/uptime.png | Bin 0 -> 980 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 screenshots/shortcut.png create mode 100644 screenshots/uptime.png diff --git a/screenshots/shortcut.png b/screenshots/shortcut.png new file mode 100644 index 0000000000000000000000000000000000000000..96bce8c45045c29b4d45454a368e07fdfbd8b686 GIT binary patch literal 1110 zcmV-c1gZOpP)=Aw5WKci`s78TBm3|zcz@0C0EiE%_~px5WG-&X88Ft}0y4<~0)Oz@iz zAM0i;YMQn5|NsAa5&o@@2@1E8;YcVdppTGaO{rKtokDrKl$M3&?2VE-g zv^IV5_WhQ_Cm9$Re*gKic-vklQv)U@Mq&*8^yTZE_1npI6DteLpTB?q|NlS0L13V! zv}*SuIQQSbe|t`zBgVwZW!Vr$+x!*JU%y3`65{9ewY5-_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-contributed modules --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9adb18b..3822e52 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Test Coverage](https://codeclimate.com/github/tobi-wan-kenobi/bumblebee-status/badges/coverage.svg)](https://codeclimate.com/github/tobi-wan-kenobi/bumblebee-status/coverage) [![Issue Count](https://codeclimate.com/github/tobi-wan-kenobi/bumblebee-status/badges/issue_count.svg)](https://codeclimate.com/github/tobi-wan-kenobi/bumblebee-status) -**Many, many thanks to all contributors! As of now, 22 of the modules are from various contributors (!), and only 16 from myself.** +**Many, many thanks to all contributors! As of now, 24 of the modules are from various contributors (!), and only 16 from myself.** bumblebee-status is a modular, theme-able status line generator for the [i3 window manager](https://i3wm.org/). From 34ac317bfa122fcbb8d87c96b95fbeb02e34bf9f Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Sat, 18 Nov 2017 09:25:02 +0100 Subject: [PATCH 6/7] Use absolute_import in uptime module --- bumblebee/modules/uptime.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bumblebee/modules/uptime.py b/bumblebee/modules/uptime.py index e7e68c9..34e4085 100644 --- a/bumblebee/modules/uptime.py +++ b/bumblebee/modules/uptime.py @@ -2,6 +2,10 @@ """Displays the system uptime.""" +# Use absolute_import because there's already a datatime module +# in the same directory +from __future__ import absolute_import + import bumblebee.input import bumblebee.output import bumblebee.engine From 8a0fae529a5e5e80ab96649cf9cc2ea992569d4c Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Sat, 18 Nov 2017 11:26:42 +0100 Subject: [PATCH 7/7] Revert "[modules/datetime] Rename datetime to date-time" This reverts commit 4bc96987db391f6ea179eb15e142c9e0e753cfae. --- bumblebee/modules/{date-time.py => datetime.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename bumblebee/modules/{date-time.py => datetime.py} (100%) diff --git a/bumblebee/modules/date-time.py b/bumblebee/modules/datetime.py similarity index 100% rename from bumblebee/modules/date-time.py rename to bumblebee/modules/datetime.py