diff --git a/README.md b/README.md index d72027c..f4ab1ee 100644 --- a/README.md +++ b/README.md @@ -208,7 +208,8 @@ All configuration options are in `~/.config/caelestia/cli.json`. "enableWarp": true, "enableChromium": true, "enableZed": true, - "enableCava": true + "enableCava": true, + "postHook": "echo $SCHEME_NAME $SCHEME_FLAVOUR $SCHEME_MODE $SCHEME_VARIANT $SCHEME_COLOURS" }, "toggles": { "communication": { diff --git a/src/caelestia/utils/theme.py b/src/caelestia/utils/theme.py index 2fdafd3..9fc95f4 100644 --- a/src/caelestia/utils/theme.py +++ b/src/caelestia/utils/theme.py @@ -1,5 +1,6 @@ import fcntl import json +import os import re import shutil import subprocess @@ -17,6 +18,7 @@ from caelestia.utils.paths import ( user_config_path, user_templates_dir, ) +from caelestia.utils.scheme import get_scheme def gen_conf(colours: dict[str, str]) -> str: @@ -456,6 +458,22 @@ def apply_colours(colours: dict[str, str], mode: str) -> None: apply_cava(colours) apply_user_templates(colours, mode) + if post_hook := cfg.get("postHook"): + scheme = get_scheme() + subprocess.run( + post_hook, + shell=True, + env={ + **os.environ, + "SCHEME_NAME": scheme.name, + "SCHEME_FLAVOUR": scheme.flavour, + "SCHEME_MODE": scheme.mode, + "SCHEME_VARIANT": scheme.variant, + "SCHEME_COLOURS": json.dumps(scheme.colours), + }, + stderr=subprocess.DEVNULL, + ) + finally: try: lock_file.unlink()