diff --git a/bumblebee_status/core/theme.py b/bumblebee_status/core/theme.py index b52c465..800bd66 100644 --- a/bumblebee_status/core/theme.py +++ b/bumblebee_status/core/theme.py @@ -7,6 +7,7 @@ import glob import core.event import util.algorithm +import util.xresources log = logging.getLogger(__name__) @@ -89,13 +90,21 @@ class Theme(object): try: if isinstance(name, dict): return name + + result = {} if name.lower() == "wal": wal = self.__load_json("~/.cache/wal/colors.json") - result = {} for field in ["special", "colors"]: for key in wal.get(field, {}): result[key] = wal[field][key] - return result + if name.lower() == "xresources": + for key in ("background", "foreground"): + result[key] = xresources.query(key) + for i in range(16): + key = color + str(i) + result[key] = xresources.query(key) + + return result except Exception as e: log.error("failed to load colors: {}", e) diff --git a/bumblebee_status/util/xresources.py b/bumblebee_status/util/xresources.py new file mode 100644 index 0000000..70665a9 --- /dev/null +++ b/bumblebee_status/util/xresources.py @@ -0,0 +1,10 @@ +import subprocess +import shutil + +def query(key): + if shutil.which("xgetres"): + return subprocess.run(["xgetres", key], + capture_output=True).stdout.decode("utf-8").strip() + else: + raise Exception("xgetres must be installed for this theme") +