From a22f16a84f9ca08441e0920fb3197edf0fe92f3b Mon Sep 17 00:00:00 2001 From: Makesesama Date: Mon, 29 Sep 2025 18:32:05 +0200 Subject: [PATCH] fix: run --- bar/main.py | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/bar/main.py b/bar/main.py index b8ecb62..6c6fc5e 100644 --- a/bar/main.py +++ b/bar/main.py @@ -22,7 +22,7 @@ from fabric.utils import ( ) from .modules.bar import StatusBar from .modules.window_fuzzy import FuzzyWindowFinder -from .modules.stylix import get_colors_css_path +from .modules.stylix import get_stylix_css_path from .config import STYLIX @@ -36,29 +36,20 @@ bar_windows = [] app = Application("bar", dummy, finder) -# Generate colors.css (either Stylix or default) in XDG config directory -colors_css_path = get_colors_css_path() -if colors_css_path: - # Update main.css to import the generated colors.css - import tempfile - with open(get_relative_path("styles/main.css"), "r") as f: - main_css = f.read() - - # Replace the colors.css import with our generated file path - updated_main_css = main_css.replace( - '@import url("./colors.css");', - f'@import url("file://{colors_css_path}");' - ) - - # Write updated main.css to temp file and load it - with tempfile.NamedTemporaryFile(mode="w", suffix=".css", delete=False) as temp_main: - temp_main.write(updated_main_css) - temp_main_path = temp_main.name - - logger.info(f"[Bar] Loading CSS with colors from {colors_css_path}") - app.set_stylesheet_from_file(temp_main_path) +# Load CSS - use Stylix if enabled, otherwise use default +if STYLIX.get("enable", False): + stylix_css_path = get_stylix_css_path() + if stylix_css_path: + logger.info("[Bar] Using Stylix CSS") + # Load base styles first for structure + app.set_stylesheet_from_file(get_relative_path("styles/main.css")) + # Then apply Stylix theme colors + app.set_stylesheet_from_file(stylix_css_path) + else: + logger.warning("[Bar] Stylix enabled but CSS generation failed, falling back to default") + app.set_stylesheet_from_file(get_relative_path("styles/main.css")) else: - logger.error("[Bar] Failed to generate colors.css, falling back to default") + logger.info("[Bar] Using default CSS") app.set_stylesheet_from_file(get_relative_path("styles/main.css"))