mirror of
https://github.com/caelestia-dots/cli.git
synced 2026-06-20 07:50:00 -05:00
fix: Lua dispatcher compat (#112)
* fix: temporary Lua dispatcher compat for workspace dispatchers * fix(resizer): add Lua dispatcher compat for window resize/move/float/center * feat(theme): write current.lua for Hyprland Lua config, current.conf for hyprlang * fix: align gen_lua format with #111 * refactor address review feedback refactor(hypr,theme): address review feedback - cache is_lua_config result to avoid redundant socket calls - remove is_lua_config wrapper, rename _is_lua_config to is_lua_config - move hypr import to top of theme.py - use single line syntax in apply_hypr and apply_colours * restore original specialws behavior and some formatting
This commit is contained in:
@@ -19,6 +19,7 @@ from caelestia.utils.paths import (
|
||||
user_templates_dir,
|
||||
)
|
||||
from caelestia.utils.scheme import get_scheme
|
||||
from caelestia.utils.hypr import is_lua_config
|
||||
|
||||
|
||||
def gen_conf(colours: dict[str, str]) -> str:
|
||||
@@ -27,6 +28,12 @@ def gen_conf(colours: dict[str, str]) -> str:
|
||||
conf += f"${name} = {colour}\n"
|
||||
return conf
|
||||
|
||||
def gen_lua(colours: dict[str, str]) -> str:
|
||||
lua = "return {\n"
|
||||
for name, colour in colours.items():
|
||||
lua += f' {name} = "{colour}",\n'
|
||||
lua += "}"
|
||||
return lua
|
||||
|
||||
def gen_scss(colours: dict[str, str]) -> str:
|
||||
scss = ""
|
||||
@@ -144,7 +151,8 @@ def apply_terms(sequences: str) -> None:
|
||||
|
||||
@log_exception
|
||||
def apply_hypr(conf: str) -> None:
|
||||
write_file(config_dir / "hypr/scheme/current.conf", conf)
|
||||
ext = "lua" if is_lua_config() else "conf"
|
||||
write_file(config_dir / f"hypr/scheme/current.{ext}", conf)
|
||||
|
||||
|
||||
@log_exception
|
||||
@@ -428,7 +436,7 @@ def apply_colours(colours: dict[str, str], mode: str) -> None:
|
||||
if check("enableTerm"):
|
||||
apply_terms(gen_sequences(colours))
|
||||
if check("enableHypr"):
|
||||
apply_hypr(gen_conf(colours))
|
||||
apply_hypr(gen_lua(colours) if is_lua_config() else gen_conf(colours))
|
||||
if check("enableDiscord"):
|
||||
apply_discord(gen_scss(colours))
|
||||
if check("enableSpicetify"):
|
||||
|
||||
Reference in New Issue
Block a user