dev mode
This commit is contained in:
@@ -54,3 +54,4 @@ BATTERY = app_config.get("battery", {"enable": False})
|
|||||||
WINDOW_TITLE = app_config.get("window_title", {"enable": True})
|
WINDOW_TITLE = app_config.get("window_title", {"enable": True})
|
||||||
STYLIX = app_config.get("stylix", {"enable": False})
|
STYLIX = app_config.get("stylix", {"enable": False})
|
||||||
BAR_HEIGHT = app_config.get("height", 40)
|
BAR_HEIGHT = app_config.get("height", 40)
|
||||||
|
DEV = app_config.get("dev", False)
|
||||||
|
|||||||
48
bar/main.py
48
bar/main.py
@@ -1,5 +1,16 @@
|
|||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
|
# Configure logging based on dev flag
|
||||||
|
from .config import DEV
|
||||||
|
if DEV:
|
||||||
|
# In dev mode, disable fabric logs but keep stylix and bar logs
|
||||||
|
logger.disable("fabric")
|
||||||
|
else:
|
||||||
|
# In production, disable all debug logs, only keep warnings and errors
|
||||||
|
logger.disable("fabric")
|
||||||
|
logger.disable("bar")
|
||||||
|
logger.configure(handlers=[{"sink": lambda msg: print(msg, end=""), "level": "WARNING"}])
|
||||||
|
|
||||||
from fabric import Application
|
from fabric import Application
|
||||||
from fabric.system_tray.widgets import SystemTray
|
from fabric.system_tray.widgets import SystemTray
|
||||||
from fabric.widgets.wayland import WaylandWindow as Window
|
from fabric.widgets.wayland import WaylandWindow as Window
|
||||||
@@ -11,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_stylix_css_path
|
from .modules.stylix import get_colors_css_path
|
||||||
from .config import STYLIX
|
from .config import STYLIX
|
||||||
|
|
||||||
|
|
||||||
@@ -25,20 +36,29 @@ bar_windows = []
|
|||||||
|
|
||||||
app = Application("bar", dummy, finder)
|
app = Application("bar", dummy, finder)
|
||||||
|
|
||||||
# Load CSS - use Stylix if enabled, otherwise use default
|
# Generate colors.css (either Stylix or default) in XDG config directory
|
||||||
if STYLIX.get("enable", False):
|
colors_css_path = get_colors_css_path()
|
||||||
stylix_css_path = get_stylix_css_path()
|
if colors_css_path:
|
||||||
if stylix_css_path:
|
# Update main.css to import the generated colors.css
|
||||||
logger.info("[Bar] Using Stylix CSS")
|
import tempfile
|
||||||
# Load base styles first for structure
|
with open(get_relative_path("styles/main.css"), "r") as f:
|
||||||
app.set_stylesheet_from_file(get_relative_path("styles/main.css"))
|
main_css = f.read()
|
||||||
# Then apply Stylix theme colors
|
|
||||||
app.set_stylesheet_from_file(stylix_css_path)
|
# 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)
|
||||||
else:
|
else:
|
||||||
logger.warning("[Bar] Stylix enabled but CSS generation failed, falling back to default")
|
logger.error("[Bar] Failed to generate colors.css, 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"))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
height: 42
|
height: 42
|
||||||
|
dev: true
|
||||||
window_title:
|
window_title:
|
||||||
enable: false
|
enable: false
|
||||||
vinyl:
|
vinyl:
|
||||||
|
|||||||
Reference in New Issue
Block a user