From 83bb1deb52807d0d10f33c8a2141592aeb33e0e4 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Mon, 31 Oct 2016 11:46:07 +0100 Subject: [PATCH] [themes] Add cycling for individual elements Add functionality to provide lists of values for individual elements of a theme (e.g. the prefix) and those will be cycled for each call. This can be used, for example, to show a "charging" symbol for the battery that continuously goes throw all the battery stages to "animate" the charging icon. --- bumblebee/modules/battery.py | 2 ++ bumblebee/theme.py | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/bumblebee/modules/battery.py b/bumblebee/modules/battery.py index 2c779e8..4feb5e8 100644 --- a/bumblebee/modules/battery.py +++ b/bumblebee/modules/battery.py @@ -28,5 +28,7 @@ class Module(bumblebee.module.Module): return "discharging_high" return "discharging_full" else: + if self._capacity > 95: + return "charged" return "charging" # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 diff --git a/bumblebee/theme.py b/bumblebee/theme.py index 6cf115d..78d5f34 100644 --- a/bumblebee/theme.py +++ b/bumblebee/theme.py @@ -11,6 +11,7 @@ class Theme: self._data = json.load(f) self._defaults = self._data.get("defaults", {}) self._cycle = self._defaults.get("cycle", []) + self._modules = {} self.reset() @@ -30,6 +31,16 @@ class Theme: value = state_theme.get(key, value) + if type(value) is list: + # cycle through the values + if not obj in self._modules: + self._modules[obj] = { "idx": 0 } + else: + self._modules[obj]["idx"] += 1 + if self._modules[obj]["idx"] >= len(value): + self._modules[obj]["idx"] = 0 + value = value[self._modules[obj]["idx"]] + return value def reset(self):