feat: stylix support
This commit is contained in:
@@ -52,4 +52,5 @@ if app_config is None:
|
||||
VINYL = app_config.get("vinyl", {"enable": False})
|
||||
BATTERY = app_config.get("battery", {"enable": False})
|
||||
WINDOW_TITLE = app_config.get("window_title", {"enable": True})
|
||||
STYLIX = app_config.get("stylix", {"enable": False})
|
||||
BAR_HEIGHT = app_config.get("height", 40)
|
||||
|
||||
18
bar/main.py
18
bar/main.py
@@ -11,6 +11,8 @@ from fabric.utils import (
|
||||
)
|
||||
from .modules.bar import StatusBar
|
||||
from .modules.window_fuzzy import FuzzyWindowFinder
|
||||
from .modules.stylix import get_stylix_css_path
|
||||
from .config import STYLIX
|
||||
|
||||
|
||||
tray = SystemTray(name="system-tray", spacing=4)
|
||||
@@ -22,7 +24,21 @@ finder = FuzzyWindowFinder()
|
||||
bar_windows = []
|
||||
|
||||
app = Application("bar", dummy, finder)
|
||||
app.set_stylesheet_from_file(get_relative_path("styles/main.css"))
|
||||
|
||||
# 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")
|
||||
app.set_stylesheet_from_file(stylix_css_path)
|
||||
# Also load base styles for imports
|
||||
app.set_stylesheet_from_file(get_relative_path("styles/main.css"))
|
||||
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.info("[Bar] Using default CSS")
|
||||
app.set_stylesheet_from_file(get_relative_path("styles/main.css"))
|
||||
|
||||
|
||||
def spawn_bars():
|
||||
|
||||
172
bar/modules/stylix.py
Normal file
172
bar/modules/stylix.py
Normal file
@@ -0,0 +1,172 @@
|
||||
from bar.config import STYLIX
|
||||
import tempfile
|
||||
import os
|
||||
|
||||
|
||||
def generate_stylix_css():
|
||||
"""Generate CSS using Stylix colors if enabled"""
|
||||
if not STYLIX.get("enable", False):
|
||||
return None
|
||||
|
||||
colors = STYLIX.get("colors", {})
|
||||
fonts = STYLIX.get("fonts", {})
|
||||
|
||||
# Default colors if Stylix is not properly configured
|
||||
default_colors = {
|
||||
"base00": "1e1e2e", # background
|
||||
"base01": "313244", # lighter background
|
||||
"base02": "45475a", # selection background
|
||||
"base03": "585b70", # comments
|
||||
"base04": "bac2de", # dark foreground
|
||||
"base05": "cdd6f4", # foreground
|
||||
"base06": "f5e0dc", # light foreground
|
||||
"base07": "b4befe", # light background
|
||||
"base08": "f38ba8", # red
|
||||
"base09": "fab387", # orange
|
||||
"base0A": "f9e2af", # yellow
|
||||
"base0B": "a6e3a1", # green
|
||||
"base0C": "94e2d5", # cyan
|
||||
"base0D": "89b4fa", # blue
|
||||
"base0E": "cba6f7", # purple
|
||||
"base0F": "f2cdcd", # brown
|
||||
}
|
||||
|
||||
# Use Stylix colors or fallback to defaults
|
||||
for key in default_colors:
|
||||
if key not in colors:
|
||||
colors[key] = default_colors[key]
|
||||
|
||||
# Default font
|
||||
font_family = fonts.get("sansSerif", "sans-serif")
|
||||
font_size = fonts.get("sizes", {}).get("applications", 14)
|
||||
|
||||
css_content = f"""
|
||||
/* Stylix-generated colors */
|
||||
:root {{
|
||||
--window-bg: #{colors["base00"]};
|
||||
--module-bg: #{colors["base01"]};
|
||||
--border-color: #{colors["base02"]};
|
||||
--foreground: #{colors["base05"]};
|
||||
--red: #{colors["base08"]};
|
||||
--orange: #{colors["base09"]};
|
||||
--yellow: #{colors["base0A"]};
|
||||
--green: #{colors["base0B"]};
|
||||
--cyan: #{colors["base0C"]};
|
||||
--blue: #{colors["base0D"]};
|
||||
--violet: #{colors["base0E"]};
|
||||
--purple: #{colors["base0E"]};
|
||||
--brown: #{colors["base0F"]};
|
||||
}}
|
||||
|
||||
/* Apply Stylix font */
|
||||
* {{
|
||||
font-family: "{font_family}", sans-serif;
|
||||
font-size: {font_size}px;
|
||||
}}
|
||||
|
||||
/* Workspace styling */
|
||||
.workspace-button {{
|
||||
background-color: #{colors["base01"]};
|
||||
color: #{colors["base05"]};
|
||||
border: 1px solid #{colors["base02"]};
|
||||
border-radius: 4px;
|
||||
padding: 4px 8px;
|
||||
margin: 2px;
|
||||
}}
|
||||
|
||||
.workspace-button.active {{
|
||||
background-color: #{colors["base0D"]};
|
||||
color: #{colors["base00"]};
|
||||
}}
|
||||
|
||||
.workspace-button.urgent {{
|
||||
background-color: #{colors["base08"]};
|
||||
color: #{colors["base00"]};
|
||||
}}
|
||||
|
||||
/* Bar styling */
|
||||
#bar-inner {{
|
||||
background-color: #{colors["base00"]};
|
||||
border-bottom: 2px solid #{colors["base02"]};
|
||||
}}
|
||||
|
||||
/* System tray */
|
||||
#system-tray {{
|
||||
background-color: #{colors["base01"]};
|
||||
border-radius: 4px;
|
||||
}}
|
||||
|
||||
/* Date time */
|
||||
#date-time {{
|
||||
color: #{colors["base05"]};
|
||||
background-color: #{colors["base01"]};
|
||||
padding: 4px 8px;
|
||||
border-radius: 4px;
|
||||
}}
|
||||
|
||||
/* Progress bars */
|
||||
#cpu-progress-bar {{
|
||||
color: #{colors["base0E"]};
|
||||
}}
|
||||
|
||||
#ram-progress-bar,
|
||||
#volume-progress-bar {{
|
||||
color: #{colors["base0D"]};
|
||||
}}
|
||||
|
||||
/* Battery */
|
||||
#battery-widget {{
|
||||
background-color: #{colors["base01"]};
|
||||
border-radius: 4px;
|
||||
}}
|
||||
|
||||
#bat-icon {{
|
||||
color: #{colors["base0D"]};
|
||||
}}
|
||||
|
||||
#bat-label {{
|
||||
color: #{colors["base05"]};
|
||||
}}
|
||||
|
||||
#bat-label.battery-low {{
|
||||
color: #{colors["base08"]};
|
||||
}}
|
||||
|
||||
/* Active window */
|
||||
.active-window {{
|
||||
color: #{colors["base05"]};
|
||||
}}
|
||||
|
||||
/* NixOS label */
|
||||
#nixos-label {{
|
||||
color: #{colors["base0D"]};
|
||||
}}
|
||||
|
||||
/* Widgets container */
|
||||
#widgets-container {{
|
||||
background-color: #{colors["base01"]};
|
||||
border-radius: 4px;
|
||||
}}
|
||||
|
||||
/* Tooltip */
|
||||
tooltip {{
|
||||
background-color: #{colors["base00"]};
|
||||
border: 2px solid #{colors["base02"]};
|
||||
color: #{colors["base05"]};
|
||||
}}
|
||||
"""
|
||||
|
||||
# Write to temporary file
|
||||
temp_fd, temp_path = tempfile.mkstemp(suffix='.css', prefix='stylix_')
|
||||
try:
|
||||
with os.fdopen(temp_fd, 'w') as f:
|
||||
f.write(css_content)
|
||||
return temp_path
|
||||
except Exception:
|
||||
os.close(temp_fd)
|
||||
return None
|
||||
|
||||
|
||||
def get_stylix_css_path():
|
||||
"""Get the path to the Stylix CSS file"""
|
||||
return generate_stylix_css()
|
||||
@@ -45,7 +45,8 @@
|
||||
}
|
||||
)
|
||||
// {
|
||||
homeManagerModules.makku-bar =
|
||||
homeManagerModules = {
|
||||
makku-bar =
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
@@ -127,5 +128,7 @@
|
||||
};
|
||||
};
|
||||
};
|
||||
stylix-makku-bar = import ./nix/stylix/hm.nix;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
44
nix/stylix/hm.nix
Normal file
44
nix/stylix/hm.nix
Normal file
@@ -0,0 +1,44 @@
|
||||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.stylix.targets.makku-bar;
|
||||
in
|
||||
{
|
||||
options.stylix.targets.makku-bar.enable =
|
||||
config.lib.stylix.mkEnableTarget "Makku Bar" true;
|
||||
|
||||
config = lib.mkIf (config.stylix.enable && cfg.enable) {
|
||||
services.makku-bar.settings.stylix = {
|
||||
enable = true;
|
||||
colors = {
|
||||
base00 = config.lib.stylix.colors.base00; # background
|
||||
base01 = config.lib.stylix.colors.base01; # lighter background
|
||||
base02 = config.lib.stylix.colors.base02; # selection background
|
||||
base03 = config.lib.stylix.colors.base03; # comments
|
||||
base04 = config.lib.stylix.colors.base04; # dark foreground
|
||||
base05 = config.lib.stylix.colors.base05; # foreground
|
||||
base06 = config.lib.stylix.colors.base06; # light foreground
|
||||
base07 = config.lib.stylix.colors.base07; # light background
|
||||
base08 = config.lib.stylix.colors.base08; # red
|
||||
base09 = config.lib.stylix.colors.base09; # orange
|
||||
base0A = config.lib.stylix.colors.base0A; # yellow
|
||||
base0B = config.lib.stylix.colors.base0B; # green
|
||||
base0C = config.lib.stylix.colors.base0C; # cyan
|
||||
base0D = config.lib.stylix.colors.base0D; # blue
|
||||
base0E = config.lib.stylix.colors.base0E; # purple
|
||||
base0F = config.lib.stylix.colors.base0F; # brown
|
||||
};
|
||||
fonts = {
|
||||
serif = config.stylix.fonts.serif.name;
|
||||
sansSerif = config.stylix.fonts.sansSerif.name;
|
||||
monospace = config.stylix.fonts.monospace.name;
|
||||
sizes = {
|
||||
desktop = config.stylix.fonts.sizes.desktop;
|
||||
applications = config.stylix.fonts.sizes.applications;
|
||||
terminal = config.stylix.fonts.sizes.terminal;
|
||||
popups = config.stylix.fonts.sizes.popups;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
6
nix/stylix/meta.nix
Normal file
6
nix/stylix/meta.nix
Normal file
@@ -0,0 +1,6 @@
|
||||
{ lib }:
|
||||
{
|
||||
name = "Makku Bar";
|
||||
homepage = "https://github.com/Makesesama/makku-bar";
|
||||
maintainers = [ ];
|
||||
}
|
||||
Reference in New Issue
Block a user