From 2756f8fbb3efeccb9554ab51c26e730cb07901c1 Mon Sep 17 00:00:00 2001 From: tobi-wan-kenobi Date: Thu, 2 Apr 2020 12:51:08 +0200 Subject: [PATCH] [core/theme] Fix retrieval of rotating theme values (e.g. battery) When rotating theme values (e.g. the "charge" icon of the battery module(s)), until now, the code just showed the raw list (because it wasn't aware of the need to rotate). --- core/theme.py | 6 ++++++ doc/NOTES.md | 1 + 2 files changed, 7 insertions(+) diff --git a/core/theme.py b/core/theme.py index 5b5efff..305442f 100644 --- a/core/theme.py +++ b/core/theme.py @@ -116,6 +116,12 @@ class Theme(object): if not type(value) in (list, dict): value = self.__keywords.get(value, value) + + if isinstance(value, list): + key = '__{}-idx__'.format(key) + idx = widget.get(key, 0) + widget.set(key, (idx + 1) % len(value)) + value = value[idx] self.__current[key] = value return value diff --git a/doc/NOTES.md b/doc/NOTES.md index 4440fe5..f729d3e 100644 --- a/doc/NOTES.md +++ b/doc/NOTES.md @@ -35,3 +35,4 @@ - themes: use colors to improve theme readability - brightness: read from CLI tools - input: use events? +- themes: rotating icons (battery!)