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.bar import StatusBar
|
||||||
from .modules.window_fuzzy import FuzzyWindowFinder
|
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
|
from .config import STYLIX
|
||||||
|
|
||||||
|
|
||||||
@@ -36,29 +36,20 @@ bar_windows = []
|
|||||||
|
|
||||||
app = Application("bar", dummy, finder)
|
app = Application("bar", dummy, finder)
|
||||||
|
|
||||||
# Generate colors.css (either Stylix or default) in XDG config directory
|
# Load CSS - use Stylix if enabled, otherwise use default
|
||||||
colors_css_path = get_colors_css_path()
|
if STYLIX.get("enable", False):
|
||||||
if colors_css_path:
|
stylix_css_path = get_stylix_css_path()
|
||||||
# Update main.css to import the generated colors.css
|
if stylix_css_path:
|
||||||
import tempfile
|
logger.info("[Bar] Using Stylix CSS")
|
||||||
with open(get_relative_path("styles/main.css"), "r") as f:
|
# Load base styles first for structure
|
||||||
main_css = f.read()
|
app.set_stylesheet_from_file(get_relative_path("styles/main.css"))
|
||||||
|
# Then apply Stylix theme colors
|
||||||
# Replace the colors.css import with our generated file path
|
app.set_stylesheet_from_file(stylix_css_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)
|
|
||||||
else:
|
else:
|
||||||
logger.error("[Bar] Failed to generate colors.css, falling back to default")
|
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.info("[Bar] Using default CSS")
|
||||||
app.set_stylesheet_from_file(get_relative_path("styles/main.css"))
|
app.set_stylesheet_from_file(get_relative_path("styles/main.css"))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user