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
@@ -217,6 +217,11 @@ mkdir -p "$TARGET_ROOTFS/home/user/.cache" "$TARGET_ROOTFS/home/user/.config" \
|
||||
"$TARGET_ROOTFS/home/user/.local/share/geminux" \
|
||||
"$TARGET_ROOTFS/home/user/Pictures" "$TARGET_ROOTFS/home/user/Videos" \
|
||||
"$TARGET_ROOTFS/home/user/Downloads"
|
||||
if [ -x "$TARGET_ROOTFS/usr/bin/geminux-sync-gtk-theme" ]; then
|
||||
HOME="$TARGET_ROOTFS/etc/skel" \
|
||||
GEMINUX_XRESOURCES="$TARGET_ROOTFS/etc/skel/.Xresources" \
|
||||
"$TARGET_ROOTFS/usr/bin/geminux-sync-gtk-theme" --no-reload
|
||||
fi
|
||||
if [ -d "$TARGET_ROOTFS/etc/skel" ]; then
|
||||
cp -af "$TARGET_ROOTFS/etc/skel/." "$TARGET_ROOTFS/home/user/"
|
||||
fi
|
||||
|
||||
@@ -34,7 +34,7 @@ for bad_pkg in sway wayfire weston phosh cage xwayland grim slurp wofi \
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
for req_pkg in ffmpeg mpv gst-libav; do
|
||||
for req_pkg in ffmpeg mpv gst-libav xsettingsd; do
|
||||
if ! grep -Fxq "P:$req_pkg" "$ROOTFS_DIR/lib/apk/db/installed"; then
|
||||
echo "FAIL: expected native package '$req_pkg' is not installed in rootfs" >&2
|
||||
exit 1
|
||||
@@ -364,6 +364,15 @@ for req_rel in ("etc/pam.d/autologin", "etc/init.d/geminux-hwinit",
|
||||
"root/.config/htop/htoprc",
|
||||
"root/.lynx.cfg",
|
||||
"root/.apexrc",
|
||||
"usr/bin/xsetroot",
|
||||
"usr/bin/xsettingsd",
|
||||
"usr/bin/geminux-sync-gtk-theme",
|
||||
"etc/skel/.gtkrc-2.0",
|
||||
"etc/skel/.config/gtk-3.0/settings.ini",
|
||||
"etc/skel/.config/xsettingsd/xsettingsd.conf",
|
||||
"home/user/.gtkrc-2.0",
|
||||
"home/user/.config/gtk-3.0/settings.ini",
|
||||
"home/user/.config/xsettingsd/xsettingsd.conf",
|
||||
"etc/NetworkManager/dispatcher.d/30-geminux-chrony",
|
||||
"etc/polkit-1/rules.d/10-geminux.rules"):
|
||||
if not os.path.lexists(os.path.join(rootfs, req_rel)):
|
||||
|
||||
@@ -183,6 +183,7 @@ xkeyboard-config
|
||||
xrandr
|
||||
xrdb
|
||||
xset
|
||||
xsettingsd
|
||||
xsetroot
|
||||
yabasic
|
||||
yt-dlp-core
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -67,9 +67,11 @@ int main(int argc, char** argv) {
|
||||
::setenv("WEBKIT_DISABLE_DMABUF_RENDERER", "0", 1);
|
||||
::setenv("WEBKIT_DISABLE_COMPOSITING_MODE", "0", 1);
|
||||
::setenv("JSC_useJIT", "0", 1);
|
||||
::unsetenv("GTK_THEME");
|
||||
configureWebkitRenderer(false);
|
||||
CHECK(::getenv("WEBKIT_DISABLE_DMABUF_RENDERER") == nullptr);
|
||||
CHECK(::getenv("WEBKIT_DISABLE_COMPOSITING_MODE") == nullptr);
|
||||
CHECK(::getenv("GTK_THEME") == nullptr);
|
||||
CHECK(std::string(::getenv("JSC_useJIT")) == "0");
|
||||
|
||||
FILE* f = std::fopen(flag.c_str(), "wb");
|
||||
|
||||
Reference in new issue
Block a user