Synchronize active GTK2 and GTK3 themes with .xth theme selection
This commit is contained in:
1 parent
21485612fb
commit
16fcaaaba6
16 files changed
+949
-16
No files matched your search
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Verify all Geminux .xth themes and dunst theme synchronization."""
|
||||
"""Verify all Geminux .xth themes, dunst synchronization, and GTK2/GTK3 synchronization."""
|
||||
|
||||
import glob
|
||||
import os
|
||||
@@ -11,6 +11,9 @@ import tempfile
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
THEMES_DIR = os.path.join(BASE_DIR, "overlay", "rootfs", "etc", "skel", ".xthemes")
|
||||
SYNC_SCRIPT = os.path.join(BASE_DIR, "overlay", "rootfs", "usr", "bin", "geminux-sync-dunst-theme")
|
||||
GTK_SYNC_SCRIPT = os.path.join(BASE_DIR, "overlay", "rootfs", "usr", "bin", "geminux-sync-gtk-theme")
|
||||
|
||||
LIGHT_THEMES = frozenset({"CatppuccinLatte", "GruvboxLight", "SolarizedLight"})
|
||||
|
||||
REQUIRED_KEYS = (
|
||||
"theme.name", "theme.fontFace", "theme.iconFontFace", "theme.baseFontSize",
|
||||
@@ -42,7 +45,7 @@ def main():
|
||||
assert len(themes) >= 20, f"Expected >= 20 themes, found {len(themes)}"
|
||||
|
||||
with tempfile.TemporaryDirectory(prefix="geminux-dunst-test-") as tmp:
|
||||
for th in themes:
|
||||
for idx, th in enumerate(themes):
|
||||
vals = parse_xres(th)
|
||||
for req in REQUIRED_KEYS:
|
||||
assert req in vals and vals[req], f"Missing {req} in {os.path.basename(th)}"
|
||||
@@ -66,7 +69,76 @@ def main():
|
||||
assert "font = Fira Code " in txt
|
||||
assert "width = 720" in txt
|
||||
|
||||
print(f"[PASS] Verified {len(themes)} .xth themes and dunst synchronization")
|
||||
th_home = os.path.join(tmp, f"home-{idx}")
|
||||
os.makedirs(th_home, exist_ok=True)
|
||||
gtk_env = {
|
||||
k: v for k, v in os.environ.items()
|
||||
if k not in (
|
||||
"GEMINUX_GTK_THEMES_DIR", "GEMINUX_XDG_THEMES_DIR",
|
||||
"GEMINUX_GTK2_RC", "GEMINUX_GTK3_DIR", "GEMINUX_XSETTINGSD_CONF",
|
||||
)
|
||||
}
|
||||
gtk_env["HOME"] = th_home
|
||||
gtk_env["GEMINUX_XRESOURCES"] = th
|
||||
subprocess.run([GTK_SYNC_SCRIPT, "--no-reload"], env=gtk_env, check=True)
|
||||
|
||||
tname = vals["theme.name"]
|
||||
gtk_name = f"Geminux-{tname}"
|
||||
theme_root = os.path.join(th_home, ".themes", gtk_name)
|
||||
is_light = tname in LIGHT_THEMES
|
||||
|
||||
for cfg_rel in (".gtkrc-2.0", ".config/gtk-3.0/settings.ini", ".config/xsettingsd/xsettingsd.conf"):
|
||||
cfg_path = os.path.join(th_home, cfg_rel)
|
||||
with open(cfg_path, encoding="utf-8") as cf:
|
||||
cfg_txt = cf.read()
|
||||
assert gtk_name in cfg_txt, f"Missing {gtk_name} in {cfg_rel} for {tname}"
|
||||
assert "/tmp" not in cfg_txt and "/home" not in cfg_txt, (
|
||||
f"Hardcoded path leaked into {cfg_rel} for {tname}: {cfg_txt}"
|
||||
)
|
||||
|
||||
with open(os.path.join(th_home, ".config/gtk-3.0/settings.ini"), encoding="utf-8") as sf:
|
||||
ini_txt = sf.read()
|
||||
exp_dark_bool = "false" if is_light else "true"
|
||||
assert f"gtk-application-prefer-dark-theme={exp_dark_bool}" in ini_txt, (
|
||||
f"Expected gtk-application-prefer-dark-theme={exp_dark_bool} for {tname}"
|
||||
)
|
||||
|
||||
with open(os.path.join(th_home, ".config/xsettingsd/xsettingsd.conf"), encoding="utf-8") as xf:
|
||||
xsd_txt = xf.read()
|
||||
assert f'Net/ThemeName "{gtk_name}"' in xsd_txt
|
||||
assert "Xft/DPI" not in xsd_txt, f"Unexpected Xft/DPI in xsettingsd.conf for {tname}"
|
||||
|
||||
with open(os.path.join(theme_root, "index.theme"), encoding="utf-8") as itf:
|
||||
idx_txt = itf.read()
|
||||
assert f"GtkTheme={gtk_name}" in idx_txt
|
||||
|
||||
with open(os.path.join(theme_root, "gtk-2.0/gtkrc"), encoding="utf-8") as rc2f:
|
||||
rc2_txt = rc2f.read()
|
||||
assert 'engine "' not in rc2_txt, f"External GTK2 engine referenced in {tname}"
|
||||
for ck in ("theme.bgMain", "theme.fgMain", "theme.selBg", "theme.accent"):
|
||||
assert vals[ck] in rc2_txt, f"Missing {ck} in gtkrc for {tname}"
|
||||
|
||||
with open(os.path.join(theme_root, "gtk-3.0/gtk.css"), encoding="utf-8") as css3f:
|
||||
css3_txt = css3f.read()
|
||||
exp_base = "gtk-contained.css" if is_light else "gtk-contained-dark.css"
|
||||
assert f'@import url("resource:///org/gtk/libgtk/theme/Adwaita/{exp_base}");' in css3_txt, (
|
||||
f"Wrong Adwaita base CSS in {tname}: expected {exp_base}"
|
||||
)
|
||||
assert css3_txt.count("{") == css3_txt.count("}"), f"Unbalanced braces in gtk.css for {tname}"
|
||||
for ck in ("theme.bgMain", "theme.fgMain", "theme.selBg", "theme.accent", "theme.dangerBg"):
|
||||
assert vals[ck] in css3_txt, f"Missing {ck} in gtk.css for {tname}"
|
||||
|
||||
with open(os.path.join(theme_root, "gtk-3.0/gtk-dark.css"), encoding="utf-8") as css3df:
|
||||
assert '@import url("gtk.css");' in css3df.read()
|
||||
|
||||
xdg_link = os.path.join(th_home, ".local/share/themes", gtk_name)
|
||||
assert os.path.islink(xdg_link), f"Missing XDG symlink {xdg_link}"
|
||||
assert os.readlink(xdg_link) == f"../../../.themes/{gtk_name}", (
|
||||
f"Unexpected XDG symlink target for {tname}: {os.readlink(xdg_link)}"
|
||||
)
|
||||
assert os.path.isfile(os.path.join(xdg_link, "gtk-3.0/gtk.css"))
|
||||
|
||||
print(f"[PASS] Verified {len(themes)} .xth themes, dunst synchronization, and GTK2/GTK3 theme generation")
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user