From e2a6d413897d0331b8ad60e73c0c9a7cece1c646 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Sat, 5 Nov 2016 16:53:18 +0100 Subject: [PATCH] [theme] Add YAML as optional format for themes This addresses issue #4 --- bumblebee/theme.py | 10 ++++-- bumblebee/themes/default.yaml | 60 +++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 bumblebee/themes/default.yaml diff --git a/bumblebee/theme.py b/bumblebee/theme.py index 657a4be..4dee7a7 100644 --- a/bumblebee/theme.py +++ b/bumblebee/theme.py @@ -1,5 +1,6 @@ import os import json +import yaml import glob def getpath(): @@ -12,8 +13,13 @@ def themes(): class Theme: def __init__(self, config): self._config = config - with open("{}/{}.json".format(getpath(), config.theme())) as f: - self._data = json.load(f) + + if os.path.isfile("{}/{}.yaml".format(getpath(), config.theme())): + with open("{}/{}.yaml".format(getpath(), config.theme())) as f: + self._data = yaml.load(f) + else: + with open("{}/{}.json".format(getpath(), config.theme())) as f: + self._data = json.load(f) self._defaults = self._data.get("defaults", {}) self._cycles = self._defaults.get("cycle", []) self.begin() diff --git a/bumblebee/themes/default.yaml b/bumblebee/themes/default.yaml new file mode 100644 index 0000000..4beca6d --- /dev/null +++ b/bumblebee/themes/default.yaml @@ -0,0 +1,60 @@ +defaults: + prefix: " " + suffix: " " + urgent: true + fg: "#aabbcc" +date: + prefix: " " +time: + prefix: " " +memory: + prefix: " ram " +cpu: + prefix: " cpu " +disk: + prefix: " hdd " +dnf: + prefix: " dnf " +pasink: + states: + muted: + prefix: " audio(mute) " + unmuted: + prefix: " audio " +pasource: + states: + muted: + prefix: " mic(mute) " + unmuted: + prefix: " mic " +nic: + states: + "wireless-up": + prefix: " wifi " + "wireless-down": + prefix: " wifi " + "wired-up": + prefix: " lan " + "wired-down": + prefix: " lan " + "tunnel-up": + prefix: " tun " + "tunnel-down": + prefix: " tun " +battery: + states: + charged: + suffix: " full " + charging: + suffix: " chr " + discharging_critical: + prefix: " ! " + suffix: " dis " + discharging_low: + suffix: " dis " + discharging_medium: + suffix: " dis " + discharging_high: + suffix: " dis " + discharging_full: + suffix: " dis "