From dc85a8e936f097634722c27b5bdc12ab2af09449 Mon Sep 17 00:00:00 2001 From: Arjun Nair Date: Sat, 9 Sep 2017 23:26:39 +0530 Subject: [PATCH 01/23] Removed returning n/a Better not to show --- bumblebee/modules/battery.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bumblebee/modules/battery.py b/bumblebee/modules/battery.py index f5e565e..61741ed 100644 --- a/bumblebee/modules/battery.py +++ b/bumblebee/modules/battery.py @@ -58,9 +58,9 @@ class Module(bumblebee.engine.Module): if estimate == power.common.TIME_REMAINING_UNLIMITED: return None if estimate == power.common.TIME_REMAINING_UNKNOWN: - return "n/a" + return "" except Exception: - return "n/a" + return "" return bumblebee.util.durationfmt(estimate*60, shorten=True, suffix=True) # estimate is in minutes def capacity(self, widget): From a6d76538737ad1fdf8745d07b3e1ec13f62038f5 Mon Sep 17 00:00:00 2001 From: Arjun Nair Date: Sun, 10 Sep 2017 00:23:41 +0530 Subject: [PATCH 02/23] Added parameter showname to hide network interface Becomes a needless info for personal laptop usages where only one interface is used. --- bumblebee/modules/traffic.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bumblebee/modules/traffic.py b/bumblebee/modules/traffic.py index ee21794..fa84321 100644 --- a/bumblebee/modules/traffic.py +++ b/bumblebee/modules/traffic.py @@ -5,6 +5,7 @@ Parameters: * traffic.exclude: Comma-separated list of interface prefixes to exclude (defaults to "lo,virbr,docker,vboxnet,veth") * traffic.states: Comma-separated list of states to show (prefix with "^" to invert - i.e. ^down -> show all devices that are not in state down) + * traffic.showname: set as False to hide network interface name """ import re @@ -23,6 +24,7 @@ class Module(bumblebee.engine.Module): self._exclude = tuple(filter(len, self.parameter("exclude", "lo,virbr,docker,vboxnet,veth").split(","))) self._status = "" + self._showname = self.parameter("showname", "True") self._prev = {} self._states = {} self._states["include"] = [] @@ -85,8 +87,9 @@ class Module(bumblebee.engine.Module): } name = "traffic-{}".format(interface) - - self.create_widget(widgets, name, interface) + + if self._showname != "False": + self.create_widget(widgets, name, interface) for direction in ["rx", "tx"]: name = "traffic.{}-{}".format(direction, interface) From 5551eb1d74bb34a59de36bd51ed9e742bfcceeac Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Sun, 10 Sep 2017 09:16:21 +0200 Subject: [PATCH 03/23] [modules/traffic] Use boolean util methods see #171 --- bumblebee/modules/traffic.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bumblebee/modules/traffic.py b/bumblebee/modules/traffic.py index fa84321..60d5dd7 100644 --- a/bumblebee/modules/traffic.py +++ b/bumblebee/modules/traffic.py @@ -5,7 +5,7 @@ Parameters: * traffic.exclude: Comma-separated list of interface prefixes to exclude (defaults to "lo,virbr,docker,vboxnet,veth") * traffic.states: Comma-separated list of states to show (prefix with "^" to invert - i.e. ^down -> show all devices that are not in state down) - * traffic.showname: set as False to hide network interface name + * traffic.showname: If set to False, hide network interface name (defaults to True) """ import re @@ -24,7 +24,7 @@ class Module(bumblebee.engine.Module): self._exclude = tuple(filter(len, self.parameter("exclude", "lo,virbr,docker,vboxnet,veth").split(","))) self._status = "" - self._showname = self.parameter("showname", "True") + self._showname = bumblebee.util.asbool(self.parameter("showname", True)) self._prev = {} self._states = {} self._states["include"] = [] @@ -88,7 +88,7 @@ class Module(bumblebee.engine.Module): name = "traffic-{}".format(interface) - if self._showname != "False": + if self._showname: self.create_widget(widgets, name, interface) for direction in ["rx", "tx"]: From bf53c5912c144932cf4511e921d0eaaa018d2b90 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Sun, 10 Sep 2017 09:34:02 +0200 Subject: [PATCH 04/23] [modules/currency] Enable base and symbol configuration The "base" currency can now be configured using the parameter "source", and the "symbols" to be resolved can be configured using the parameter "destination", which is a comma-separated list. see #169 --- bumblebee/modules/currency.py | 48 +++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/bumblebee/modules/currency.py b/bumblebee/modules/currency.py index 488eebb..068a6f6 100644 --- a/bumblebee/modules/currency.py +++ b/bumblebee/modules/currency.py @@ -8,6 +8,10 @@ Requires the following python packages: Parameters: * currency.interval: Interval in minutes between updates, default is 1. + * currency.source: Source currency (defaults to "GBP") + * currency.destination: Comma-separated list of destination currencies (defaults to "USD,EUR") + +Note: source and destination names right now must correspond to the names used by the API of http://fixer.io """ import bumblebee.input @@ -21,40 +25,40 @@ try: except ImportError: pass +SYMBOL = { + "GBP": u"£", "EUR": u"€", "USD": u"$" +} + class Module(bumblebee.engine.Module): def __init__(self, engine, config): super(Module, self).__init__(engine, config, bumblebee.output.Widget(full_text=self.price) ) - self._price = "-" - self._interval = int(self.parameter("interval", "1")) + self._data = {} + self._interval = int(self.parameter("interval", 1)) + self._base = self.parameter("source", "GBP") + self._symbols = self.parameter("destination", "USD,EUR") self._nextcheck = 0 - self._valid = False def price(self, widget): - if not self._valid: - return u"?" - return self._price + if self._data == {}: + return "?" + + rates = [] + for sym in self._data["rates"]: + rates.append(u"{}{}".format(self._data["rates"][sym], SYMBOL[sym] if sym in SYMBOL else sym)) + + return u"{}: {}".format(SYMBOL[self._base] if self._base in SYMBOL else self._base, u"/".join(rates)) def update(self, widgets): timestamp = int(time.time()) if self._nextcheck < int(time.time()): + self._data = {} + self._nextcheck = int(time.time()) + self._interval*60 + url = "http://api.fixer.io/latest?symbols={}&base={}".format(self._symbols, self._base) try: - self._nextcheck = int(time.time()) + self._interval*60 - price_url = "http://api.fixer.io/latest?symbols=USD,EUR&base=GBP" - try: - price_json = json.loads( requests.get(price_url).text ) - gbpeur = str(price_json['rates']['EUR']) - gbpusd = str(price_json['rates']['USD']) - except ValueError: - gbpeur = "-" - gbpusd = "-" - - self._price = u"£/€ " + gbpeur + u" | £/$ " + gbpusd - self._valid = True - except RequestException: - self._price = u"£/€ - | £/$ -" - self._valid = True + self._data = json.loads(requests.get(url).text) + except Exception: + pass # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 - From 75140c77b40b802c8b9c587785557123321707ea Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Sun, 10 Sep 2017 18:37:11 +0200 Subject: [PATCH 05/23] [modules/currency] Make output format configurable Add two format strings: * sourceformat to specify the "base" format * destinationdelimiter to format how multiple rates are delimited --- bumblebee/modules/currency.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bumblebee/modules/currency.py b/bumblebee/modules/currency.py index 068a6f6..81d533e 100644 --- a/bumblebee/modules/currency.py +++ b/bumblebee/modules/currency.py @@ -10,6 +10,9 @@ Parameters: * currency.interval: Interval in minutes between updates, default is 1. * currency.source: Source currency (defaults to "GBP") * currency.destination: Comma-separated list of destination currencies (defaults to "USD,EUR") + * currency.sourceformat: String format for source formatting; Defaults to "{}: {}" and has two variables, + the base symbol and the rate list + * currency.destinationdelimiter: Delimiter used for separating individual rates (defaults to "|") Note: source and destination names right now must correspond to the names used by the API of http://fixer.io """ @@ -48,7 +51,10 @@ class Module(bumblebee.engine.Module): for sym in self._data["rates"]: rates.append(u"{}{}".format(self._data["rates"][sym], SYMBOL[sym] if sym in SYMBOL else sym)) - return u"{}: {}".format(SYMBOL[self._base] if self._base in SYMBOL else self._base, u"/".join(rates)) + basefmt = u"{}".format(self.parameter("sourceformat", "{}: {}")) + ratefmt = u"{}".format(self.parameter("destinationdelimiter", "|")) + + return basefmt.format(SYMBOL[self._base] if self._base in SYMBOL else self._base, ratefmt.join(rates)) def update(self, widgets): timestamp = int(time.time()) From 55f48d561877a11febc2e5cb09621d5519251c24 Mon Sep 17 00:00:00 2001 From: Pier-Angelo Gaetani Date: Fri, 15 Sep 2017 09:51:14 -0600 Subject: [PATCH 06/23] Added title module. --- bumblebee/modules/title.py | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 bumblebee/modules/title.py diff --git a/bumblebee/modules/title.py b/bumblebee/modules/title.py new file mode 100644 index 0000000..f062214 --- /dev/null +++ b/bumblebee/modules/title.py @@ -0,0 +1,46 @@ +# pylint: disable=C0111,R0903 + +"""Displays focused i3 window title. + +Requirements: + * i3ipc + +Parameters: + * title.max : Maximum character length for title before truncating. Defaults to 64. + * title.placeholder : Placeholder text to be placed if title was truncated. Defaults to "...". +""" + +try: + import i3ipc +except ImportError: + pass + +import bumblebee.util +import bumblebee.input +import bumblebee.output +import bumblebee.engine +import textwrap + +class Module(bumblebee.engine.Module): + """Window title module.""" + + def __init__(self, engine, config): + super(Module, self).__init__(engine, config, + bumblebee.output.Widget(full_text=self.focused_title) + ) + self._i3 = i3ipc.Connection() + self._full_title = self._i3.get_tree().find_focused().name + + def focused_title(self, widget): + """Truncates and returns proper-length title.""" + return textwrap.shorten( + self._full_title, + width=float(self.parameter("max", 64)), + placeholder=self.parameter("placeholder", "...") + ) + + def update(self, widgets): + """Update current title.""" + self._full_title = self._i3.get_tree().find_focused().name + +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 From 8bba1d1e0dd6160ae1084e49cee6a82fe1f80211 Mon Sep 17 00:00:00 2001 From: Pier-Angelo Gaetani Date: Fri, 15 Sep 2017 10:03:58 -0600 Subject: [PATCH 07/23] [module/title] Requirement update in README.md + linting --- README.md | 1 + bumblebee/modules/title.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8c8b6c6..001cb69 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,7 @@ Modules and commandline utilities are only required for modules, the core itself * requests (for the modules 'weather', 'github', 'getcrypto', 'stock') * power (for the module 'battery') * dbus (for the module 'spotify') +* i3rpc (for the module 'title') # Required commandline utilities diff --git a/bumblebee/modules/title.py b/bumblebee/modules/title.py index f062214..0bf0589 100644 --- a/bumblebee/modules/title.py +++ b/bumblebee/modules/title.py @@ -15,23 +15,25 @@ try: except ImportError: pass +import textwrap import bumblebee.util import bumblebee.input import bumblebee.output import bumblebee.engine -import textwrap class Module(bumblebee.engine.Module): """Window title module.""" def __init__(self, engine, config): - super(Module, self).__init__(engine, config, + super(Module, self).__init__( + engine, + config, bumblebee.output.Widget(full_text=self.focused_title) ) self._i3 = i3ipc.Connection() self._full_title = self._i3.get_tree().find_focused().name - def focused_title(self, widget): + def focused_title(self): """Truncates and returns proper-length title.""" return textwrap.shorten( self._full_title, From ad1832a57d145f61737c784de0d8971ba2a5671b Mon Sep 17 00:00:00 2001 From: Pier-Angelo Gaetani Date: Fri, 15 Sep 2017 10:36:20 -0600 Subject: [PATCH 08/23] [module/title] Added pip dependency to travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 0e198ad..61e1ff9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ python: - "3.5" - "3.6" install: + - pip install i3ipc - pip install psutil - pip install netifaces - pip install -U coverage==4.3 From ecbde508d2c3bef82df08ff3af2c1f0b035c7431 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Fri, 15 Sep 2017 20:00:57 +0200 Subject: [PATCH 09/23] [modules/title] Python < 3.4 compatibility Replace textwrap.shorten() with custom implementation, since it is only available since Python 3.4. While at it, catch i3 exceptions in order to make unit tests (hopefully) run through. Also, Updated README.md see #174 --- README.md | 2 +- bumblebee/modules/title.py | 15 +++++++-------- screenshots/title.png | Bin 0 -> 4458 bytes 3 files changed, 8 insertions(+), 9 deletions(-) create mode 100644 screenshots/title.png diff --git a/README.md b/README.md index 001cb69..27e8f1b 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, 21 of the modules are from various contributors (!), and only 16 from myself.** +**Many, many thanks to all contributors! As of now, 22 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/). diff --git a/bumblebee/modules/title.py b/bumblebee/modules/title.py index 0bf0589..959c44a 100644 --- a/bumblebee/modules/title.py +++ b/bumblebee/modules/title.py @@ -15,7 +15,6 @@ try: except ImportError: pass -import textwrap import bumblebee.util import bumblebee.input import bumblebee.output @@ -33,13 +32,13 @@ class Module(bumblebee.engine.Module): self._i3 = i3ipc.Connection() self._full_title = self._i3.get_tree().find_focused().name - def focused_title(self): - """Truncates and returns proper-length title.""" - return textwrap.shorten( - self._full_title, - width=float(self.parameter("max", 64)), - placeholder=self.parameter("placeholder", "...") - ) + def focused_title(self, widget): + title = self._full_title[0:self.parameter("max", 64)] + if title != self._full_title: + title = self._full_title[0:self.parameter("max", 64) - 3] + title = "{}...".format(title) + + return title def update(self, widgets): """Update current title.""" diff --git a/screenshots/title.png b/screenshots/title.png new file mode 100644 index 0000000000000000000000000000000000000000..1089a0b9a9d1e341475511f46169a1d46bedd23e GIT binary patch literal 4458 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 LYI3y@i+BG6%kyNw literal 0 HcmV?d00001 From 4a9782a517e0069d4f8b04c118f53e2b6dc7541a Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Fri, 15 Sep 2017 20:05:09 +0200 Subject: [PATCH 10/23] [modules/title] Make unittests run through see #174 --- bumblebee/modules/title.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bumblebee/modules/title.py b/bumblebee/modules/title.py index 959c44a..f54fa7c 100644 --- a/bumblebee/modules/title.py +++ b/bumblebee/modules/title.py @@ -29,8 +29,11 @@ class Module(bumblebee.engine.Module): config, bumblebee.output.Widget(full_text=self.focused_title) ) - self._i3 = i3ipc.Connection() - self._full_title = self._i3.get_tree().find_focused().name + try: + self._i3 = i3ipc.Connection() + self._full_title = self._i3.get_tree().find_focused().name + except Exception: + self._full_title = "n/a" def focused_title(self, widget): title = self._full_title[0:self.parameter("max", 64)] @@ -42,6 +45,9 @@ class Module(bumblebee.engine.Module): def update(self, widgets): """Update current title.""" - self._full_title = self._i3.get_tree().find_focused().name + try: + self._full_title = self._i3.get_tree().find_focused().name + except Exception: + self._full_title = "n/a" # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 From da21eba0d7ce645910a4b0c5b0c73f483ec33176 Mon Sep 17 00:00:00 2001 From: Pier-Angelo Gaetani Date: Fri, 15 Sep 2017 17:46:24 -0600 Subject: [PATCH 11/23] [module/title] added scrollable title option --- bumblebee/modules/title.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/bumblebee/modules/title.py b/bumblebee/modules/title.py index f54fa7c..ce09c36 100644 --- a/bumblebee/modules/title.py +++ b/bumblebee/modules/title.py @@ -8,6 +8,7 @@ Requirements: Parameters: * title.max : Maximum character length for title before truncating. Defaults to 64. * title.placeholder : Placeholder text to be placed if title was truncated. Defaults to "...". + * title.scroll : Boolean flag for scrolling title. Defaults to False """ try: @@ -20,6 +21,8 @@ import bumblebee.input import bumblebee.output import bumblebee.engine +from bumblebee.output import scrollable + class Module(bumblebee.engine.Module): """Window title module.""" @@ -27,7 +30,7 @@ class Module(bumblebee.engine.Module): super(Module, self).__init__( engine, config, - bumblebee.output.Widget(full_text=self.focused_title) + bumblebee.output.Widget(full_text=self.get_title) ) try: self._i3 = i3ipc.Connection() @@ -35,14 +38,25 @@ class Module(bumblebee.engine.Module): except Exception: self._full_title = "n/a" + def get_title(self, widget): + if self.parameter("scroll", "False").lower() == "true": + return self.scrolling_focused_title(widget) + else: + return self.focused_title(widget) + def focused_title(self, widget): title = self._full_title[0:self.parameter("max", 64)] + placeholder = self.parameter("placeholder", "...") if title != self._full_title: - title = self._full_title[0:self.parameter("max", 64) - 3] - title = "{}...".format(title) + title = self._full_title[0:self.parameter("max", 64) - len(placeholder)] + title = "{}{}".format(title, placeholder) return title + @scrollable + def scrolling_focused_title(self, widget): + return self._full_title + def update(self, widgets): """Update current title.""" try: From dfb1e394214d8d308e842952f92fbbe5c41c7607 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Sat, 16 Sep 2017 12:22:20 +0200 Subject: [PATCH 12/23] [core + modules/cmus] Have another go at fixing unicode issues Override sys.stdout and sys.stderr in an attempt to enforce utf-8 encoding. Probably this will cause all kinds of weird issues down the line, but at least, it seems to solve the immediate issue. fixes #176 --- bumblebee-status | 25 +++++++++++++++++++++++++ bumblebee/modules/cmus.py | 5 ----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/bumblebee-status b/bumblebee-status index f28dc7c..41e8636 100755 --- a/bumblebee-status +++ b/bumblebee-status @@ -10,6 +10,28 @@ import bumblebee.output import bumblebee.input import bumblebee.modules.error +# taken from +# https://stackoverflow.com/a/42146082 +# seems an excellent solution to me +class SmartStdout: + def __init__(self, encoding=None, org_stdout=None): + if org_stdout is None: + org_stdout = getattr(sys.stdout, 'org_stdout', sys.stdout) + self.org_stdout = org_stdout + self.encoding = encoding or getattr(org_stdout, 'encoding', None) or 'utf-8' + + def write(self, s): + self.org_stdout.write(s.encode(self.encoding, 'backslashreplace')) + + def __getattr__(self, name): + return getattr(self.org_stdout, name) + +def set_defaultencoding_globally(encoding='utf-8'): + assert sys.getdefaultencoding() in ('ascii', 'mbcs', encoding) + import imp + _sys_org = imp.load_dynamic('_sys_org', 'sys') + _sys_org.setdefaultencoding(encoding) + def main(): config = bumblebee.config.Config(sys.argv[1:]) @@ -63,6 +85,9 @@ def main(): time.sleep(1) if __name__ == "__main__": + if sys.stdout.isatty(): + sys.stdout = sys.stderr = SmartStdout() + set_defaultencoding_globally('utf-8') main() # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 diff --git a/bumblebee/modules/cmus.py b/bumblebee/modules/cmus.py index 62fbfaf..2db4c0c 100644 --- a/bumblebee/modules/cmus.py +++ b/bumblebee/modules/cmus.py @@ -1,5 +1,4 @@ # pylint: disable=C0111,R0903 -# -*- coding: utf-8 -*- """Displays information about the current song in cmus. @@ -69,10 +68,6 @@ class Module(bumblebee.engine.Module): return returns.get(widget.name, self._status) def _eval_line(self, line): - # not a typo, use decode detection to see whether we are - # dealing with Python2 or Python3 - if hasattr(line, "decode"): - line = line.encode("utf-8", "replace") name, key, value = (line.split(" ", 2) + [None, None])[:3] if name == "status": From d1d431ec6d9cca2d95e5878d2b4b2774f67d9097 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Sat, 16 Sep 2017 16:48:13 +0200 Subject: [PATCH 13/23] [doc] Include required i3wm version in README.md fixes #173 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 27e8f1b..aaf0e30 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ I hope you like it and appreciate any kind of feedback: Bug reports, Feature req Thanks a lot! +Required i3wm version: 4.12+ (in earlier versions, blocks won't have background colors) + Supported Python versions: 2.7, 3.3, 3.4, 3.5, 3.6 Explicitly unsupported Python versions: 3.2 (missing unicode literals) From 43c26390ed25339f9f5870f6b3b8af734a2aa6b3 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Sun, 17 Sep 2017 14:35:53 +0200 Subject: [PATCH 14/23] [packaging] Add PKGBUILD for AUR building AUR package for released versions of bumblebee-status should now be available here: https://aur.archlinux.org/packages/bumblebee-status/ fixes #172 --- PKGBUILD | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 PKGBUILD diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..ff7335e --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,37 @@ +# Maintainer: Tobias Witek +# Contributor: Daniel M. Capella + +pkgname=bumblebee-status +pkgver=1.4.2 +pkgrel=1 +pkgdesc='Modular, theme-able status line generator for the i3 window manager' +arch=('any') +url=https://github.com/tobi-wan-kenobi/bumblebee-status +license=('MIT') +depends=('python-netifaces' 'python-psutil' 'python-requests') +optdepends=('xorg-xbacklight: to display a displays brightness' + 'xorg-xset: enable/disable automatic screen locking' + 'libnotify: enable/disable automatic screen locking' + 'dnf: display DNF package update information' + 'xorg-setxkbmap: display/change the current keyboard layout' + 'redshift: display the redshifts current color' + 'pulseaudio: control pulseaudio sink/sources' + 'xorg-xrandr: enable/disable screen outputs' + 'pacman: display current status of pacman' + 'iputils: display a ping' + 'i3ipc: display titlebar' + 'fakeroot: dependency of the pacman module') +source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz") +sha512sums=('3a66fc469dd3b081337c9e213a1b2262f25f30977ee6ef65b9fa5a8b6aa341637832d1a5dbb74e30d68e2824e0d19d7a911eb3390dc6062707a552f429b483e8') + +package() { + install -d "$pkgdir"/usr/bin \ + "$pkgdir"/usr/share/$pkgname/{bumblebee/modules,themes/icons} + ln -s /usr/share/$pkgname/$pkgname "$pkgdir"/usr/bin/$pkgname + + cd $pkgname-$pkgver + cp -a --parents $pkgname bumblebee/{,modules/}*.py themes/{,icons/}*.json \ + "$pkgdir"/usr/share/$pkgname + + install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE +} From e079c07363e07b3227b47a55a83481f964236978 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Sun, 17 Sep 2017 16:10:06 +0200 Subject: [PATCH 15/23] [aur] Add python dependency and update optional dependencies Add python to the list of mandatory dependencies and fix the dependency name of python-i3ipc. --- PKGBUILD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index ff7335e..15d0e43 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -8,7 +8,7 @@ pkgdesc='Modular, theme-able status line generator for the i3 window manager' arch=('any') url=https://github.com/tobi-wan-kenobi/bumblebee-status license=('MIT') -depends=('python-netifaces' 'python-psutil' 'python-requests') +depends=('python' 'python-netifaces' 'python-psutil' 'python-requests') optdepends=('xorg-xbacklight: to display a displays brightness' 'xorg-xset: enable/disable automatic screen locking' 'libnotify: enable/disable automatic screen locking' @@ -19,7 +19,7 @@ optdepends=('xorg-xbacklight: to display a displays brightness' 'xorg-xrandr: enable/disable screen outputs' 'pacman: display current status of pacman' 'iputils: display a ping' - 'i3ipc: display titlebar' + 'i3ipc-python: display titlebar' 'fakeroot: dependency of the pacman module') source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz") sha512sums=('3a66fc469dd3b081337c9e213a1b2262f25f30977ee6ef65b9fa5a8b6aa341637832d1a5dbb74e30d68e2824e0d19d7a911eb3390dc6062707a552f429b483e8') From 42b42c1294144e18af999bb04a3e161cf9a2988b Mon Sep 17 00:00:00 2001 From: Christopher Mullins Date: Sun, 17 Sep 2017 18:46:40 -0400 Subject: [PATCH 16/23] BUG: github module count breaks in python3 In python2, filter returned a list, but in python3 it returns an iterator. So we wrap this in a list() so that it works in both. We also want to count the unread notifications, so this should be reflected in the code. --- bumblebee/modules/github.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bumblebee/modules/github.py b/bumblebee/modules/github.py index bbd3bd8..d9a5576 100644 --- a/bumblebee/modules/github.py +++ b/bumblebee/modules/github.py @@ -49,7 +49,7 @@ class Module(bumblebee.engine.Module): 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())) + self._count += len(list(filter(lambda notification: notification['unread'], notifications.json()))) next_link = notifications.links.get('next') if next_link is not None: url = next_link.get('url') From e70ba50a30b61a0458d7b107889f21d74bdd10ce Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 18 Sep 2017 08:30:44 +0200 Subject: [PATCH 17/23] [module/title] Use bumblebee.util.asbool function --- bumblebee/modules/title.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bumblebee/modules/title.py b/bumblebee/modules/title.py index ce09c36..1b5ac75 100644 --- a/bumblebee/modules/title.py +++ b/bumblebee/modules/title.py @@ -39,7 +39,7 @@ class Module(bumblebee.engine.Module): self._full_title = "n/a" def get_title(self, widget): - if self.parameter("scroll", "False").lower() == "true": + if bumblebee.util.asbool(self.parameter("scroll", False)): return self.scrolling_focused_title(widget) else: return self.focused_title(widget) From 9365e5b18a98820d7bb5b7b79569ac7038094a9f Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Mon, 18 Sep 2017 20:14:17 +0200 Subject: [PATCH 18/23] [core] Set default encoding to utf-8 Have another go at all my fun utf-8 issues. This *should* fix #180 And hopefully still fixes #176 --- bumblebee-status | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/bumblebee-status b/bumblebee-status index 41e8636..e3fe4ca 100755 --- a/bumblebee-status +++ b/bumblebee-status @@ -10,27 +10,12 @@ import bumblebee.output import bumblebee.input import bumblebee.modules.error -# taken from -# https://stackoverflow.com/a/42146082 -# seems an excellent solution to me -class SmartStdout: - def __init__(self, encoding=None, org_stdout=None): - if org_stdout is None: - org_stdout = getattr(sys.stdout, 'org_stdout', sys.stdout) - self.org_stdout = org_stdout - self.encoding = encoding or getattr(org_stdout, 'encoding', None) or 'utf-8' +try: + reload(sys) + sys.setdefaultencoding('UTF8') +except Exception: + pass - def write(self, s): - self.org_stdout.write(s.encode(self.encoding, 'backslashreplace')) - - def __getattr__(self, name): - return getattr(self.org_stdout, name) - -def set_defaultencoding_globally(encoding='utf-8'): - assert sys.getdefaultencoding() in ('ascii', 'mbcs', encoding) - import imp - _sys_org = imp.load_dynamic('_sys_org', 'sys') - _sys_org.setdefaultencoding(encoding) def main(): config = bumblebee.config.Config(sys.argv[1:]) @@ -85,9 +70,6 @@ def main(): time.sleep(1) if __name__ == "__main__": - if sys.stdout.isatty(): - sys.stdout = sys.stderr = SmartStdout() - set_defaultencoding_globally('utf-8') main() # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 From 18131a3efe53aba2d613b03584e0aa0573b44af3 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Tue, 19 Sep 2017 09:15:36 +0200 Subject: [PATCH 19/23] [modules/layout] Remove parameter for language configuration Switch layout module to do full auto-detection by parsing the output of xrandr -query. fixes #177 --- bumblebee/modules/layout.py | 66 ++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/bumblebee/modules/layout.py b/bumblebee/modules/layout.py index d9daadb..49c59a4 100644 --- a/bumblebee/modules/layout.py +++ b/bumblebee/modules/layout.py @@ -4,9 +4,6 @@ Requires the following executable: * setxkbmap - -Parameters: - * layout.lang: pipe-separated list of languages to cycle through (e.g. us|rs|de). Default: en """ import bumblebee.util @@ -17,58 +14,59 @@ import bumblebee.engine class Module(bumblebee.engine.Module): def __init__(self, engine, config): super(Module, self).__init__(engine, config, - bumblebee.output.Widget(full_text=self.layout) + bumblebee.output.Widget(full_text=self.current_layout) ) - self._languages = self.parameter("lang", "us").split("|") - self._idx = 0 - engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE, cmd=self._next_keymap) engine.input.register_callback(self, button=bumblebee.input.RIGHT_MOUSE, cmd=self._prev_keymap) def _next_keymap(self, event): - self._idx = (self._idx + 1) % len(self._languages) - self._set_keymap() + self._set_keymap(1) def _prev_keymap(self, event): - self._idx = self._idx - 1 if self._idx > 0 else len(self._languages) - 1 - self._set_keymap() + self._set_keymap(-1) + + def _set_keymap(self, rotation): + layouts = self.get_layouts() + if len(layouts) == 1: return # nothing to do + layouts = layouts[rotation:] + layouts[:rotation] + + layout_list = [] + variant_list = [] + for l in layouts: + tmp = l.split(":") + layout_list.append(tmp[0]) + variant_list.append(tmp[1] if len(tmp) > 1 else "") - def _set_keymap(self): - tmp = self._languages[self._idx].split(":") - layout = tmp[0] - variant = "" - if len(tmp) > 1: - variant = "-variant {}".format(tmp[1]) try: - bumblebee.util.execute("setxkbmap -layout {} {}".format(layout, variant)) + bumblebee.util.execute("setxkbmap -layout {} -variant {}".format(",".join(layout_list), ",".join(variant_list))) except RuntimeError: pass - def layout(self, widget): + def get_layouts(self): try: res = bumblebee.util.execute("setxkbmap -query") except RuntimeError: - return "n/a" - layout = "" - variant = None + return ["n/a"] + layouts = [] + variants = [] for line in res.split("\n"): - if not line: - continue + if not line: continue if "layout" in line: - layout = line.split(":")[1].strip() + layouts = line.split(":")[1].strip().split(",") if "variant" in line: - variant = line.split(":")[1].strip() - if variant: - layout += ":" + variant + variants = line.split(":")[1].strip().split(",") - if layout in self._languages: - self._idx = self._languages.index(layout) - else: - self._languages.append(layout) - self._idx = len(self._languages) - 1 + result = [] + for idx, layout in enumerate(layouts): + if len(variants) > idx and variants[idx]: + layout = "{}:{}".format(layout, variants[idx]) + result.append(layout) + return result if len(result) > 0 else ["n/a"] - return layout + def current_layout(self, widget): + layouts = self.get_layouts() + return layouts[0] # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 From 81e1b2568716c573dc7c4dfe30ba70b1cf25c14f Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Wed, 20 Sep 2017 06:26:39 +0200 Subject: [PATCH 20/23] [modules/memory] Use /proc/meminfo instead of psutil Try to be more accurate in calculating memory by using the /proc/meminfo interface directly. fixes #181 --- bumblebee/modules/memory.py | 38 +++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/bumblebee/modules/memory.py b/bumblebee/modules/memory.py index e92fc10..752a8a0 100644 --- a/bumblebee/modules/memory.py +++ b/bumblebee/modules/memory.py @@ -9,22 +9,24 @@ Parameters: * memory.usedonly: Only show the amount of RAM in use (defaults to False). Same as memory.format="{used}" """ -try: - import psutil -except ImportError: - pass +import re import bumblebee.util import bumblebee.input import bumblebee.output import bumblebee.engine +class Container(object): + def __init__(self, **kwargs): + self.__dict__.update(kwargs) + class Module(bumblebee.engine.Module): def __init__(self, engine, config): super(Module, self).__init__(engine, config, bumblebee.output.Widget(full_text=self.memory_usage) ) - self._mem = psutil.virtual_memory() + self.update(None) + engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE, cmd="gnome-system-monitor") @@ -36,18 +38,30 @@ class Module(bumblebee.engine.Module): return self.parameter("format", "{used}/{total} ({percent:05.02f}%)") def memory_usage(self, widget): - used = bumblebee.util.bytefmt(self._mem.total - self._mem.available) - total = bumblebee.util.bytefmt(self._mem.total) - - return self._format.format(used=used, total=total, percent=self._mem.percent) + return self._format.format(**self._mem) def update(self, widgets): - self._mem = psutil.virtual_memory() + data = {} + with open("/proc/meminfo", "r") as f: + for line in f: + tmp = re.split(r"[:\s]+", line) + value = int(tmp[1]) + if tmp[2] == "kB": value = value*1024 + if tmp[2] == "mB": value = value*1024*1024 + if tmp[2] == "gB": value = value*1024*1024*1024 + data[tmp[0]] = value + self._mem = { + "total": bumblebee.util.bytefmt(data["MemTotal"]), + "available": bumblebee.util.bytefmt(data["MemAvailable"]), + "free": bumblebee.util.bytefmt(data["MemFree"]), + "used": bumblebee.util.bytefmt(data["MemTotal"] - data["MemFree"] - data["Buffers"] - data["Cached"] - data["Slab"]), + "percent": (float(data["MemTotal"] - data["MemAvailable"])/data["MemTotal"])*100 + } def state(self, widget): - if self._mem.percent > float(self.parameter("critical", 90)): + if self._mem["percent"] > float(self.parameter("critical", 90)): return "critical" - if self._mem.percent > float(self.parameter("warning", 80)): + if self._mem["percent"] > float(self.parameter("warning", 80)): return "warning" return None From be8669270e02ad92f0dc1c274f669e3850f54ae6 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Wed, 20 Sep 2017 06:28:47 +0200 Subject: [PATCH 21/23] [tests] Removed memory test, as psutil is not used anymore mocking psutil doesn't bring much to the table now... --- tests/modules/test_memory.py | 61 ------------------------------------ 1 file changed, 61 deletions(-) delete mode 100644 tests/modules/test_memory.py diff --git a/tests/modules/test_memory.py b/tests/modules/test_memory.py deleted file mode 100644 index 3f98ca9..0000000 --- a/tests/modules/test_memory.py +++ /dev/null @@ -1,61 +0,0 @@ -# pylint: disable=C0103,C0111 - -import mock -import unittest - -import tests.mocks as mocks - -from bumblebee.input import LEFT_MOUSE -from bumblebee.modules.memory import Module - -class VirtualMemory(object): - def __init__(self, percent): - self.percent = percent - -class TestMemoryModule(unittest.TestCase): - def setUp(self): - mocks.setup_test(self, Module) - self._psutil = mock.patch("bumblebee.modules.memory.psutil") - self.psutil = self._psutil.start() - - def tearDown(self): - self._psutil.stop() - mocks.teardown_test(self) - - def test_leftclick(self): - mocks.mouseEvent(stdin=self.stdin, button=LEFT_MOUSE, inp=self.input, module=self.module) - self.popen.assert_call("gnome-system-monitor") - - def test_warning(self): - self.config.set("memory.critical", "80") - self.config.set("memory.warning", "70") - self.psutil.virtual_memory.return_value = VirtualMemory(75) - self.module.update_all() - self.assertTrue("warning" in self.module.state(self.anyWidget)) - - def test_critical(self): - self.config.set("memory.critical", "80") - self.config.set("memory.warning", "70") - self.psutil.virtual_memory.return_value = VirtualMemory(81) - self.module.update_all() - self.assertTrue("critical" in self.module.state(self.anyWidget)) - - def test_format(self): - self.config.set("memory.format", "memory used: {used}") - rv = VirtualMemory(50) - rv.total = 1000 - rv.available = 500 - self.psutil.virtual_memory.return_value = rv - self.module.update_all() - self.assertEquals("memory used: 500.00B", self.module.memory_usage(self.anyWidget)) - - def test_usage(self): - rv = VirtualMemory(50) - rv.total = 1000 - rv.available = 500 - self.psutil.virtual_memory.return_value = rv - self.module.update_all() - self.assertEquals("500.00B/1000.00B (50.00%)", self.module.memory_usage(self.anyWidget)) - self.assertEquals(None, self.module.state(self.anyWidget)) - -# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 From f3ee6e0c67eb184bb2a43c3917abc617933f479c Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Wed, 20 Sep 2017 08:59:23 +0200 Subject: [PATCH 22/23] [themes] Add non-powerline solarized-dark with awesome fonts In order to do that, change the theme engine so that a theme can override settings in the iconsets. Was probably a bug to begin with that this was not possible. --- bumblebee/modules/redshift.py | 4 ++- bumblebee/theme.py | 5 ++-- themes/solarized-dark-awesome.json | 41 ++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 themes/solarized-dark-awesome.json diff --git a/bumblebee/modules/redshift.py b/bumblebee/modules/redshift.py index 2fd1dfb..5dce616 100644 --- a/bumblebee/modules/redshift.py +++ b/bumblebee/modules/redshift.py @@ -38,7 +38,9 @@ class Module(bumblebee.engine.Module): else: self._state = "transition" transition = " ".join(line.split(" ")[2:]) - self._text = "{} {}".format(temp, transition) + self._text = temp + if transition: + self._text = "{} {}".format(temp, transition) def state(self, widget): return self._state diff --git a/bumblebee/theme.py b/bumblebee/theme.py index e16fbb6..647a823 100644 --- a/bumblebee/theme.py +++ b/bumblebee/theme.py @@ -33,9 +33,9 @@ class Theme(object): def _init(self, data): """Initialize theme from data structure""" + self._theme = data for iconset in data.get("icons", []): self._merge(data, self._load_icons(iconset)) - self._theme = data self._defaults = data.get("defaults", {}) self._cycles = self._theme.get("cycle", []) self.reset() @@ -174,7 +174,8 @@ class Theme(object): if key in target and isinstance(target[key], dict): self._merge(target[key], value) else: - target[key] = copy.deepcopy(value) + if not key in target: + target[key] = copy.deepcopy(value) return target # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 diff --git a/themes/solarized-dark-awesome.json b/themes/solarized-dark-awesome.json new file mode 100644 index 0000000..92d7d21 --- /dev/null +++ b/themes/solarized-dark-awesome.json @@ -0,0 +1,41 @@ +{ + "icons": [ "awesome-fonts" ], + "defaults": { + "separator-block-width": 0, + "separator": "", + "warning": { + "fg": "#002b36", + "bg": "#b58900" + }, + "critical": { + "fg": "#002b36", + "bg": "#dc322f" + } + }, + "cycle": [ + { "fg": "#93a1a1", "bg": "#002b36" }, + { "fg": "#eee8d5", "bg": "#586e75" } + ], + "dnf": { + "good": { + "fg": "#002b36", + "bg": "#859900" + } + }, + "pacman": { + "good": { + "fg": "#002b36", + "bg": "#859900" + } + }, + "battery": { + "charged": { + "fg": "#002b36", + "bg": "#859900" + }, + "AC": { + "fg": "#002b36", + "bg": "#859900" + } + } +} From 08c115dc7da5e6c4b9f6c1fe02d82fa29269f16c Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Wed, 20 Sep 2017 09:17:04 +0200 Subject: [PATCH 23/23] [themes] simplify solarized dark awesome --- themes/solarized-dark-awesome.json | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/themes/solarized-dark-awesome.json b/themes/solarized-dark-awesome.json index 92d7d21..1ec6dfe 100644 --- a/themes/solarized-dark-awesome.json +++ b/themes/solarized-dark-awesome.json @@ -10,12 +10,9 @@ "critical": { "fg": "#002b36", "bg": "#dc322f" - } + }, + "fg": "#93a1a1", "bg": "#002b36" }, - "cycle": [ - { "fg": "#93a1a1", "bg": "#002b36" }, - { "fg": "#eee8d5", "bg": "#586e75" } - ], "dnf": { "good": { "fg": "#002b36",