1e3adbc842
Theme centralization: - theme/colors.json is now the single source of truth for the palette. - New theme/generate-theme.py renders, at install time, the three derived artifacts into ~/.config: colors.css (waybar/wofi @import), mako config, and hyprlock-colors.conf (hyprlang $tn_* variables). - theme/colors.css removed from the repo (now generated); install.sh calls the generator instead of the old inline mako snippet. - hyprlock.conf sources the generated color file and uses $tn_* variables instead of hardcoded rgba() values. - Generator covered by theme/test_generate_theme.py. Bluetooth: - Added waybar built-in bluetooth module (config.jsonc + style.css), with bluez/bluez-utils in packages.txt. Includes design spec and implementation plan under docs/superpowers/. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
76 lines
2.7 KiB
Python
76 lines
2.7 KiB
Python
# theme/test_generate_theme.py
|
|
import importlib.util, os
|
|
|
|
_spec = importlib.util.spec_from_file_location(
|
|
"gen", os.path.join(os.path.dirname(__file__), "generate-theme.py"))
|
|
gen = importlib.util.module_from_spec(_spec)
|
|
_spec.loader.exec_module(gen)
|
|
|
|
|
|
def test_load_palette_reads_colors_json():
|
|
pal = gen.load_palette(os.path.join(os.path.dirname(__file__), "colors.json"))
|
|
assert pal["background"] == "#1d1f21"
|
|
assert pal["blue"] == "#81a2be"
|
|
|
|
|
|
def test_hex_to_hyprlock_rgba():
|
|
assert gen.hex_to_hyprlock_rgba("#81a2be") == "rgba(81a2beff)"
|
|
assert gen.hex_to_hyprlock_rgba("#1d1f21") == "rgba(1d1f21ff)"
|
|
|
|
|
|
def test_hex_to_rgb_tuple():
|
|
assert gen.hex_to_rgb("#1d1f21") == (29, 31, 33)
|
|
|
|
|
|
def test_render_colors_css():
|
|
pal = gen.load_palette(os.path.join(os.path.dirname(__file__), "colors.json"))
|
|
css = gen.render_colors_css(pal)
|
|
# base colors
|
|
assert "@define-color tn-bg #1d1f21;" in css
|
|
assert "@define-color tn-bg-alt #282a2e;" in css
|
|
assert "@define-color tn-bg-high #373b41;" in css
|
|
assert "@define-color tn-fg #c5c8c6;" in css
|
|
assert "@define-color tn-fg-dim #969896;" in css
|
|
assert "@define-color tn-fg-muted #707880;" in css
|
|
assert "@define-color tn-blue #81a2be;" in css
|
|
assert "@define-color tn-green #b5bd68;" in css
|
|
assert "@define-color tn-yellow #f0c674;" in css
|
|
assert "@define-color tn-red #cc6666;" in css
|
|
assert "@define-color tn-magenta #b294bb;" in css
|
|
assert "@define-color tn-cyan #8abeb7;" in css
|
|
# alpha variants computed from background (29,31,33)
|
|
assert "@define-color tn-bg-a90 rgba(29, 31, 33, 0.90);" in css
|
|
assert "@define-color tn-bg-a95 rgba(29, 31, 33, 0.95);" in css
|
|
assert "@define-color tn-bg-a96 rgba(29, 31, 33, 0.96);" in css
|
|
|
|
|
|
def test_render_mako_config():
|
|
pal = gen.load_palette(os.path.join(os.path.dirname(__file__), "colors.json"))
|
|
cfg = gen.render_mako_config(pal)
|
|
assert "background-color=#1d1f21" in cfg
|
|
assert "text-color=#c5c8c6" in cfg
|
|
assert "border-size=2" in cfg
|
|
assert "border-color=#81a2be" in cfg
|
|
assert "default-timeout=4000" in cfg
|
|
|
|
|
|
def test_render_hyprlock_colors():
|
|
pal = gen.load_palette(os.path.join(os.path.dirname(__file__), "colors.json"))
|
|
out = gen.render_hyprlock_colors(pal)
|
|
assert "$tn_fg = rgba(c5c8c6ff)" in out
|
|
assert "$tn_fg_dim = rgba(969896ff)" in out
|
|
assert "$tn_bg_alt = rgba(282a2eff)" in out
|
|
assert "$tn_blue = rgba(81a2beff)" in out
|
|
assert "$tn_red = rgba(cc6666ff)" in out
|
|
assert "$tn_green = rgba(b5bd68ff)" in out
|
|
|
|
|
|
if __name__ == "__main__":
|
|
test_load_palette_reads_colors_json()
|
|
test_hex_to_hyprlock_rgba()
|
|
test_hex_to_rgb_tuple()
|
|
test_render_colors_css()
|
|
test_render_mako_config()
|
|
test_render_hyprlock_colors()
|
|
print("OK")
|