diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-06-24 23:47:53 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-06-24 23:47:53 +1000 |
| commit | f47b4fe661634a0c4c5c3efda56207e7796a3957 (patch) | |
| tree | a3d55d6ed318c477983c6b07f080bfb7864f7834 /src | |
| parent | internal: lazy import stuff (diff) | |
| download | caelestia-cli-f47b4fe661634a0c4c5c3efda56207e7796a3957.tar.gz caelestia-cli-f47b4fe661634a0c4c5c3efda56207e7796a3957.tar.bz2 caelestia-cli-f47b4fe661634a0c4c5c3efda56207e7796a3957.zip | |
internal: more lazy importing
Also fix some stuff with scheme checking
Diffstat (limited to 'src')
| -rw-r--r-- | src/caelestia/utils/scheme.py | 17 | ||||
| -rw-r--r-- | src/caelestia/utils/theme.py | 5 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/caelestia/utils/scheme.py b/src/caelestia/utils/scheme.py index 678fc87..c15c9e7 100644 --- a/src/caelestia/utils/scheme.py +++ b/src/caelestia/utils/scheme.py @@ -2,7 +2,6 @@ import json import random from pathlib import Path -from caelestia.utils.material import get_colours_for_image from caelestia.utils.notify import notify from caelestia.utils.paths import atomic_dump, scheme_data_dir, scheme_path @@ -135,8 +134,8 @@ class Scheme: def set_random(self) -> None: self._name = random.choice(get_scheme_names()) - self._flavour = random.choice(get_scheme_flavours()) - self._mode = random.choice(get_scheme_modes()) + self._flavour = random.choice(get_scheme_flavours(self.name)) + self._mode = random.choice(get_scheme_modes(self.name, self.flavour)) self.update_colours() def update_colours(self) -> None: @@ -144,15 +143,19 @@ class Scheme: self.save() def _check_flavour(self) -> None: - if self._flavour not in get_scheme_flavours(self.name): - self._flavour = get_scheme_flavours()[0] + flavours = get_scheme_flavours(self.name) + if self._flavour not in flavours: + self._flavour = flavours[0] def _check_mode(self) -> None: - if self._mode not in get_scheme_modes(self.name, self.flavour): - self._mode = get_scheme_modes()[0] + modes = get_scheme_modes(self.name, self.flavour) + if self._mode not in modes: + self._mode = modes[0] def _update_colours(self) -> None: if self.name == "dynamic": + from caelestia.utils.material import get_colours_for_image + try: self._colours = get_colours_for_image() except FileNotFoundError: diff --git a/src/caelestia/utils/theme.py b/src/caelestia/utils/theme.py index 2e5521e..8897fa9 100644 --- a/src/caelestia/utils/theme.py +++ b/src/caelestia/utils/theme.py @@ -1,5 +1,4 @@ import subprocess -import tempfile from pathlib import Path from caelestia.utils.paths import c_state_dir, config_dir, templates_dir @@ -91,6 +90,8 @@ def apply_hypr(conf: str) -> None: def apply_discord(scss: str) -> None: + import tempfile + with tempfile.TemporaryDirectory("w") as tmp_dir: (Path(tmp_dir) / "_colours.scss").write_text(scss) conf = subprocess.check_output(["sass", "-I", tmp_dir, templates_dir / "discord.scss"], text=True) @@ -140,7 +141,7 @@ def apply_qt(colours: dict[str, str], mode: str) -> None: def apply_colours(colours: dict[str, str], mode: str) -> None: apply_terms(gen_sequences(colours)) - apply_hypr(gen_conf(colours)) # FIXME: LAGGY + apply_hypr(gen_conf(colours)) apply_discord(gen_scss(colours)) apply_spicetify(colours, mode) apply_fuzzel(colours) |