fix: run
This commit is contained in:
37
bar/main.py
37
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"))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user