From 31bc0d560f06a29249fdd10605ae9c9c9ec5e8cf Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sun, 15 Jun 2025 23:32:07 +1000 Subject: theme: always write --- src/caelestia/utils/theme.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/caelestia/utils/theme.py b/src/caelestia/utils/theme.py index 5e4ef83..0d72f9c 100644 --- a/src/caelestia/utils/theme.py +++ b/src/caelestia/utils/theme.py @@ -69,11 +69,9 @@ def gen_sequences(colours: dict[str, str]) -> str: ) -def try_write(path: Path, content: str) -> None: - try: - path.write_text(content) - except FileNotFoundError: - pass +def write_file(path: Path, content: str) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(content) def apply_terms(sequences: str) -> None: @@ -89,7 +87,7 @@ def apply_terms(sequences: str) -> None: def apply_hypr(conf: str) -> None: - try_write(config_dir / "hypr/scheme/current.conf", conf) + write_file(config_dir / "hypr/scheme/current.conf", conf) def apply_discord(scss: str) -> None: @@ -98,22 +96,22 @@ def apply_discord(scss: str) -> None: conf = subprocess.check_output(["sass", "-I", tmp_dir, templates_dir / "discord.scss"], text=True) for client in "Equicord", "Vencord", "BetterDiscord", "equicord", "vesktop", "legcord": - try_write(config_dir / client / "themes/caelestia.theme.css", conf) + write_file(config_dir / client / "themes/caelestia.theme.css", conf) def apply_spicetify(colours: dict[str, str], mode: str) -> None: template = gen_replace(colours, templates_dir / f"spicetify-{mode}.ini") - try_write(config_dir / "spicetify/Themes/caelestia/color.ini", template) + write_file(config_dir / "spicetify/Themes/caelestia/color.ini", template) def apply_fuzzel(colours: dict[str, str]) -> None: template = gen_replace(colours, templates_dir / "fuzzel.ini") - try_write(config_dir / "fuzzel/fuzzel.ini", template) + write_file(config_dir / "fuzzel/fuzzel.ini", template) def apply_btop(colours: dict[str, str]) -> None: template = gen_replace(colours, templates_dir / "btop.theme", hash=True) - try_write(config_dir / "btop/themes/caelestia.theme", template) + write_file(config_dir / "btop/themes/caelestia.theme", template) subprocess.run(["killall", "-USR2", "btop"]) -- cgit v1.2.3-freya