summaryrefslogtreecommitdiff
path: root/src/caelestia
diff options
context:
space:
mode:
Diffstat (limited to 'src/caelestia')
-rw-r--r--src/caelestia/utils/paths.py1
-rw-r--r--src/caelestia/utils/theme.py42
2 files changed, 34 insertions, 9 deletions
diff --git a/src/caelestia/utils/paths.py b/src/caelestia/utils/paths.py
index 923c99c..7581c51 100644
--- a/src/caelestia/utils/paths.py
+++ b/src/caelestia/utils/paths.py
@@ -15,6 +15,7 @@ c_data_dir = data_dir / "caelestia"
c_state_dir = state_dir / "caelestia"
c_cache_dir = cache_dir / "caelestia"
+user_config_path = c_config_dir / "cli.json"
cli_data_dir = Path(__file__).parent.parent / "data"
templates_dir = cli_data_dir / "templates"
user_templates_dir = c_config_dir / "templates"
diff --git a/src/caelestia/utils/theme.py b/src/caelestia/utils/theme.py
index 6136418..ead3e29 100644
--- a/src/caelestia/utils/theme.py
+++ b/src/caelestia/utils/theme.py
@@ -1,9 +1,17 @@
+import json
import re
import subprocess
from pathlib import Path
from caelestia.utils.colour import get_dynamic_colours
-from caelestia.utils.paths import c_state_dir, config_dir, templates_dir, theme_dir, user_templates_dir
+from caelestia.utils.paths import (
+ c_state_dir,
+ config_dir,
+ templates_dir,
+ theme_dir,
+ user_config_path,
+ user_templates_dir,
+)
def gen_conf(colours: dict[str, str]) -> str:
@@ -174,12 +182,28 @@ def apply_user_templates(colours: dict[str, str]) -> None:
def apply_colours(colours: dict[str, str], mode: str) -> None:
- apply_terms(gen_sequences(colours))
- apply_hypr(gen_conf(colours))
- apply_discord(gen_scss(colours))
- apply_spicetify(colours, mode)
- apply_fuzzel(colours)
- apply_btop(colours)
- apply_gtk(colours, mode)
- apply_qt(colours, mode)
+ try:
+ cfg = json.loads(user_config_path.read_text())["theme"]
+ except (FileNotFoundError, json.JSONDecodeError, KeyError):
+ cfg = {}
+
+ def check(key: str) -> bool:
+ return cfg[key] if key in cfg else True
+
+ if check("enableTerm"):
+ apply_terms(gen_sequences(colours))
+ if check("enableHypr"):
+ apply_hypr(gen_conf(colours))
+ if check("enableDiscord"):
+ apply_discord(gen_scss(colours))
+ if check("enableSpicetify"):
+ apply_spicetify(colours, mode)
+ if check("enableFuzzel"):
+ apply_fuzzel(colours)
+ if check("enableBtop"):
+ apply_btop(colours)
+ if check("enableGtk"):
+ apply_gtk(colours, mode)
+ if check("enableQt"):
+ apply_qt(colours, mode)
apply_user_templates(colours)