feat: add theme postHook

This commit is contained in:
2 * r + 2 * t
2026-05-02 22:24:26 +10:00
parent f3b13affc3
commit 5273ed514f
2 changed files with 20 additions and 1 deletions
+2 -1
View File
@@ -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": {
+18
View File
@@ -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()