From 7b48b0836537855065ff602788fc116d0d0a7ec3 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Mon, 31 Oct 2016 07:54:18 +0100 Subject: [PATCH] [themes] Add font and background colors to themes Themes can now specify "fg" (font color) and "bg" (background color) on all levels. --- bumblebee/outputs/i3.py | 4 +++- bumblebee/theme.py | 8 +++++++- bumblebee/themes/default.json | 6 ++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/bumblebee/outputs/i3.py b/bumblebee/outputs/i3.py index aca04cd..aa6db2c 100644 --- a/bumblebee/outputs/i3.py +++ b/bumblebee/outputs/i3.py @@ -12,7 +12,9 @@ class i3bar(bumblebee.output.Output): theme = obj.theme() data = { - "full_text": "{}{}{}".format(theme.prefix(obj), obj.data(), theme.suffix(obj)) + "full_text": "{}{}{}".format(theme.prefix(obj), obj.data(), theme.suffix(obj)), + "color": theme.color(obj), + "background": theme.background(obj) } if theme.default_separators(obj) == False: data["separator"] = False diff --git a/bumblebee/theme.py b/bumblebee/theme.py index bae3299..ce6a22c 100644 --- a/bumblebee/theme.py +++ b/bumblebee/theme.py @@ -13,7 +13,7 @@ class Theme: module = obj.__module__.split(".")[-1] module_theme = self._data.get(module, {}) - value = getattr(obj, key)() if hasattr(obj, key) else "" + value = getattr(obj, key)() if hasattr(obj, key) else None value = self._defaults.get(key, value) value = module_theme.get(key, value) @@ -25,6 +25,12 @@ class Theme: return value + def color(self, obj): + return self._gettheme(obj, "fg") + + def background(self, obj): + return self._gettheme(obj, "bg") + def default_separators(self, obj): return self._gettheme(obj, "default_separators") diff --git a/bumblebee/themes/default.json b/bumblebee/themes/default.json index c239d28..3a9a508 100644 --- a/bumblebee/themes/default.json +++ b/bumblebee/themes/default.json @@ -7,10 +7,12 @@ "prefix": "bat ", "states": { "charging": { - "suffix": "+ " + "suffix": "+ ", + "fg": "#00ff00" }, "discharging": { - "suffix": "- " + "suffix": "- ", + "fg": "#ff0000" } } },