diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-06-15 23:32:07 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-06-15 23:32:07 +1000 |
| commit | 31bc0d560f06a29249fdd10605ae9c9c9ec5e8cf (patch) | |
| tree | c97b8877a72cb0f7401ee4f951d0880f7d625242 /src/caelestia/utils/theme.py | |
| parent | theme: save sequences to state file (diff) | |
| download | caelestia-cli-31bc0d560f06a29249fdd10605ae9c9c9ec5e8cf.tar.gz caelestia-cli-31bc0d560f06a29249fdd10605ae9c9c9ec5e8cf.tar.bz2 caelestia-cli-31bc0d560f06a29249fdd10605ae9c9c9ec5e8cf.zip | |
theme: always write
Diffstat (limited to '')
| -rw-r--r-- | src/caelestia/utils/theme.py | 18 |
1 files changed, 8 insertions, 10 deletions
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"]) |