feat: improve session switching, fractional DPI/GTK theming, XDG launcher, CPU/RAM status, and power policy
This commit is contained in:
1 parent
72b05b650e
commit
07d9134d2d
28 files changed
+2670
-302
No files matched your search
@@ -191,6 +191,50 @@ def test_directives_includes_once_and_reload():
|
||||
kill_pids_from_file(m_once_skip)
|
||||
|
||||
|
||||
def test_exec_once_session_isolation():
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
env, _, xdg_home, _, _, bin_dir = make_base_env(tmp)
|
||||
conf_dir = os.path.join(xdg_home, "anode")
|
||||
sess_bin = os.path.join(bin_dir, "anode_sess_once")
|
||||
compile_sleep_dummy(sess_bin)
|
||||
|
||||
m_dead = os.path.join(tmp, "dead_sess.pid")
|
||||
m_live = os.path.join(tmp, "live_sess.pid")
|
||||
|
||||
dead_env = dict(env)
|
||||
dead_env["XDG_SESSION_ID"] = "anode-dead-session-999"
|
||||
dead_env["DBUS_SESSION_BUS_ADDRESS"] = "unix:path=/tmp/anode-dead-dbus-999"
|
||||
|
||||
live_env = dict(env)
|
||||
live_env["XDG_SESSION_ID"] = "anode-live-session-1"
|
||||
live_env["DBUS_SESSION_BUS_ADDRESS"] = "unix:path=/tmp/anode-live-dbus-1"
|
||||
|
||||
dead_proc = subprocess.Popen([sess_bin, m_dead], env=dead_env)
|
||||
try:
|
||||
assert wait_until(lambda: os.path.exists(m_dead), timeout=3.0)
|
||||
write_text(os.path.join(conf_dir, "autostart"), f"exec_once anode_sess_once '{m_live}'\n")
|
||||
|
||||
res1 = run_autostart(["start"], live_env)
|
||||
assert res1.returncode == 0, res1.stderr
|
||||
assert wait_until(lambda: os.path.exists(m_live), timeout=4.0), (
|
||||
"exec_once was blocked by stale process from another session"
|
||||
)
|
||||
|
||||
# Re-running start within the same session must still deduplicate
|
||||
res2 = run_autostart(["start"], live_env)
|
||||
assert res2.returncode == 0, res2.stderr
|
||||
time.sleep(0.35)
|
||||
with open(m_live, "r", encoding="utf-8") as f:
|
||||
pids = [line.strip() for line in f if line.strip()]
|
||||
assert len(pids) == 1, f"exec_once duplicated within same session: {pids}"
|
||||
finally:
|
||||
if dead_proc.poll() is None:
|
||||
dead_proc.terminate()
|
||||
dead_proc.wait(timeout=2)
|
||||
kill_pids_from_file(m_live)
|
||||
kill_pids_from_file(m_dead)
|
||||
|
||||
|
||||
def test_profiles():
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
env, _, xdg_home, _, _, _ = make_base_env(tmp)
|
||||
@@ -470,6 +514,7 @@ def test_dwm_sighup_reload_xvfb():
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_directives_includes_once_and_reload()
|
||||
test_exec_once_session_isolation()
|
||||
test_profiles()
|
||||
test_dropins_desktop_filters_and_xdg_masking()
|
||||
test_check_errors()
|
||||
|
||||
Executable
+174
@@ -0,0 +1,174 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Verify XDG Desktop Entry, Flatpak symlink, localization, and action handling in anode-launcher."""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
LAUNCHER = os.path.join(ROOT, "scripts", "anode-launcher")
|
||||
|
||||
|
||||
def write_file(path, text, mode=0o644):
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
f.write(text)
|
||||
os.chmod(path, mode)
|
||||
|
||||
|
||||
def run_launcher_list(env):
|
||||
res = subprocess.run([LAUNCHER, "--list"], env=env, capture_output=True, text=True)
|
||||
assert res.returncode == 0, f"anode-launcher --list failed: {res.stderr}"
|
||||
entries = {}
|
||||
ordered_labels = []
|
||||
for line in res.stdout.splitlines():
|
||||
if not line:
|
||||
continue
|
||||
parts = line.split("\t", 3)
|
||||
assert len(parts) == 4, f"Malformed output line: {line!r}"
|
||||
label, workdir, term, cmd = parts
|
||||
entries[label] = (workdir, term, cmd)
|
||||
ordered_labels.append(label)
|
||||
return entries, ordered_labels
|
||||
|
||||
|
||||
def test_xdg_and_flatpak_integration():
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
home = os.path.join(tmp, "home")
|
||||
xdg_data = os.path.join(tmp, "xdg_data")
|
||||
flatpak_root = os.path.join(tmp, "flatpak_exports", "share")
|
||||
flatpak_real = os.path.join(tmp, "flatpak_app")
|
||||
usr_share = os.path.join(tmp, "usr_share")
|
||||
fbin = os.path.join(tmp, "bin")
|
||||
for d in (home, xdg_data, flatpak_root, flatpak_real, usr_share, fbin):
|
||||
os.makedirs(d, exist_ok=True)
|
||||
|
||||
tool_path = os.path.join(fbin, "my_existing_tool")
|
||||
write_file(tool_path, "#!/bin/sh\nexit 0\n", 0o755)
|
||||
|
||||
# 1. Symlinked Flatpak .desktop with @@u %U @@ file-forwarding placeholders
|
||||
discord_real = os.path.join(flatpak_real, "com.discordapp.Discord.desktop")
|
||||
write_file(
|
||||
discord_real,
|
||||
"[Desktop Entry]\n"
|
||||
"Name=Discord\n"
|
||||
"GenericName=Internet Messenger\n"
|
||||
"Exec=/bin/sh -c flatpak run --file-forwarding com.discordapp.Discord @@u %U @@\n"
|
||||
"Type=Application\n",
|
||||
)
|
||||
os.makedirs(os.path.join(flatpak_root, "applications"), exist_ok=True)
|
||||
os.symlink(
|
||||
discord_real,
|
||||
os.path.join(flatpak_root, "applications", "com.discordapp.Discord.desktop"),
|
||||
)
|
||||
|
||||
# 2. Recursive subdir desktop masked by Desktop File ID in XDG_DATA_HOME
|
||||
write_file(
|
||||
os.path.join(usr_share, "applications", "sub", "nested.desktop"),
|
||||
"[Desktop Entry]\nName=NestedApp\nExec=sh -c true\nType=Application\n",
|
||||
)
|
||||
write_file(
|
||||
os.path.join(xdg_data, "applications", "sub-nested.desktop"),
|
||||
"[Desktop Entry]\nName=NestedApp\nHidden=true\nExec=sh -c true\nType=Application\n",
|
||||
)
|
||||
write_file(
|
||||
os.path.join(usr_share, "applications", "nodisp.desktop"),
|
||||
"[Desktop Entry]\nName=ShouldHide\nNoDisplay=true\nExec=sh -c true\nType=Application\n",
|
||||
)
|
||||
|
||||
# 3. OnlyShowIn / NotShowIn / TryExec filters
|
||||
write_file(
|
||||
os.path.join(usr_share, "applications", "gnomeonly.desktop"),
|
||||
"[Desktop Entry]\nName=GnomeOnly\nOnlyShowIn=GNOME;KDE;\nExec=sh -c true\nType=Application\n",
|
||||
)
|
||||
write_file(
|
||||
os.path.join(usr_share, "applications", "notanode.desktop"),
|
||||
"[Desktop Entry]\nName=NotAnode\nNotShowIn=ANODE;XFCE;\nExec=sh -c true\nType=Application\n",
|
||||
)
|
||||
write_file(
|
||||
os.path.join(usr_share, "applications", "anodeonly.desktop"),
|
||||
"[Desktop Entry]\nName=AnodeOnly\nOnlyShowIn=ANODE;\nExec=sh -c anode\nType=Application\n",
|
||||
)
|
||||
write_file(
|
||||
os.path.join(usr_share, "applications", "badtry.desktop"),
|
||||
"[Desktop Entry]\nName=BadTry\nTryExec=definitely_missing_bin_999\nExec=sh -c true\nType=Application\n",
|
||||
)
|
||||
|
||||
# 4. Terminal=true, Path=, field codes (%i %c %k %%), and Actions=
|
||||
write_file(
|
||||
os.path.join(usr_share, "applications", "termtool.desktop"),
|
||||
"[Desktop Entry]\n"
|
||||
"Name=TermTool\n"
|
||||
"Name[uk]=УкрТерм\n"
|
||||
"Icon=term-icon\n"
|
||||
"Path=/tmp\n"
|
||||
"TryExec=my_existing_tool\n"
|
||||
"Terminal=true\n"
|
||||
"Exec=my_existing_tool %i %c %k %% %f\n"
|
||||
"Actions=AltRun;\n"
|
||||
"Type=Application\n\n"
|
||||
"[Desktop Action AltRun]\n"
|
||||
"Name=Secondary\n"
|
||||
"Name[uk]=Другий\n"
|
||||
"Exec=my_existing_tool --alt\n",
|
||||
)
|
||||
|
||||
# 5. DBusActivatable=true without Exec=
|
||||
write_file(
|
||||
os.path.join(usr_share, "applications", "org.example.DbusApp.desktop"),
|
||||
"[Desktop Entry]\n"
|
||||
"Name=DbusApp\n"
|
||||
"DBusActivatable=true\n"
|
||||
"Type=Application\n",
|
||||
)
|
||||
|
||||
env = dict(os.environ)
|
||||
env["HOME"] = home
|
||||
env["XDG_DATA_HOME"] = xdg_data
|
||||
env["XDG_DATA_DIRS"] = f"{flatpak_root}:{usr_share}"
|
||||
env["XDG_CURRENT_DESKTOP"] = "ANODE"
|
||||
env["XDG_CACHE_HOME"] = os.path.join(tmp, "cache")
|
||||
env["PATH"] = fbin + ":" + env.get("PATH", "/usr/bin:/bin")
|
||||
env["LC_ALL"] = "C"
|
||||
env["LC_MESSAGES"] = "C"
|
||||
|
||||
entries, labels = run_launcher_list(env)
|
||||
|
||||
assert "Discord (Internet Messenger)" in entries, labels
|
||||
d_wd, d_tm, d_cmd = entries["Discord (Internet Messenger)"]
|
||||
assert d_tm == "0" and "@@u" not in d_cmd and "%U" not in d_cmd, d_cmd
|
||||
assert "--file-forwarding com.discordapp.Discord" in d_cmd, d_cmd
|
||||
|
||||
assert "NestedApp" not in entries, "Desktop File ID Hidden=true masking failed"
|
||||
assert "ShouldHide" not in entries, "NoDisplay=true leaked"
|
||||
assert "GnomeOnly" not in entries, "OnlyShowIn failed"
|
||||
assert "NotAnode" not in entries, "NotShowIn failed"
|
||||
assert "BadTry" not in entries, "TryExec filter failed"
|
||||
assert "AnodeOnly" in entries
|
||||
|
||||
t_lbl = "TermTool [term]"
|
||||
a_lbl = "TermTool: Secondary [term]"
|
||||
assert t_lbl in entries and a_lbl in entries, labels
|
||||
assert labels.index(a_lbl) == labels.index(t_lbl) + 1
|
||||
wd, tm, cmd = entries[t_lbl]
|
||||
assert wd == "/tmp" and tm == "1"
|
||||
assert "--icon 'term-icon' 'TermTool'" in cmd, cmd
|
||||
assert "termtool.desktop" in cmd and cmd.endswith(" %"), cmd
|
||||
assert "%f" not in cmd and "%i" not in cmd and "%c" not in cmd and "%k" not in cmd
|
||||
|
||||
assert "DbusApp" in entries
|
||||
_, _, dbus_cmd = entries["DbusApp"]
|
||||
assert "org.example.DbusApp" in dbus_cmd and "/org/example/DbusApp" in dbus_cmd, dbus_cmd
|
||||
|
||||
# 6. Localized Name[uk] check
|
||||
loc_env = dict(env)
|
||||
loc_env.pop("LC_ALL", None)
|
||||
loc_env["LC_MESSAGES"] = "uk_UA.UTF-8"
|
||||
loc_entries, loc_labels = run_launcher_list(loc_env)
|
||||
assert "УкрТерм [term]" in loc_entries, loc_labels
|
||||
assert "УкрТерм: Другий [term]" in loc_entries, loc_labels
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_xdg_and_flatpak_integration()
|
||||
print("test_launcher: ALL PASSED")
|
||||
+423
-2
@@ -274,9 +274,9 @@ def test_icccm_replace_and_client_preservation():
|
||||
assert rep.returncode == 0, f"anode-replace failed: stdout={rep.stdout} stderr={rep.stderr}"
|
||||
assert "DE: ANODE, WM: ANODE WM" in rep.stdout
|
||||
|
||||
# Original dwm must exit cleanly via SelectionClear
|
||||
# Original dwm must exit cleanly via SelectionClear (status 75)
|
||||
assert wait_until(lambda: dwm1.poll() is not None, timeout=5.0), "old dwm did not exit on SelectionClear"
|
||||
assert dwm1.returncode == 0, f"old dwm exited non-zero: {dwm1.returncode}"
|
||||
assert dwm1.returncode == 75, f"old dwm exited with {dwm1.returncode}, expected 75"
|
||||
|
||||
wm2 = get_win_prop_ulong(dpy, root, "_NET_SUPPORTING_WM_CHECK")
|
||||
assert wm2 and wm2 != wm1, f"expected new _NET_SUPPORTING_WM_CHECK window (wm1={wm1}, wm2={wm2})"
|
||||
@@ -369,6 +369,423 @@ def test_non_icccm_wm_fallback_replace():
|
||||
terminate(xvfb)
|
||||
|
||||
|
||||
def test_anode_session_holds_open_on_replace():
|
||||
disp = pick_display()
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
env = make_env(tmp, disp)
|
||||
env["XDG_CURRENT_DESKTOP"] = "ANODE"
|
||||
env["XDG_SESSION_DESKTOP"] = "anode"
|
||||
env["DESKTOP_SESSION"] = "anode"
|
||||
xvfb = subprocess.Popen(
|
||||
["Xvfb", disp, "-screen", "0", "1280x720x24", "-nolisten", "tcp"],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
)
|
||||
sess1 = None
|
||||
dpy = None
|
||||
new_pid = None
|
||||
try:
|
||||
dpy = wait_until(lambda: X11.XOpenDisplay(disp.encode()), timeout=5.0)
|
||||
assert dpy
|
||||
root = X11.XDefaultRootWindow(dpy)
|
||||
|
||||
sess1 = subprocess.Popen(
|
||||
[os.path.join(tmp, "bin", "anode-session"), "--no-autostart"],
|
||||
env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
)
|
||||
wm1 = wait_until(lambda: get_win_prop_ulong(dpy, root, "_NET_SUPPORTING_WM_CHECK"), timeout=5.0)
|
||||
assert wm1
|
||||
assert get_win_prop_str(dpy, wm1, "_NET_WM_NAME") == "ANODE WM"
|
||||
|
||||
rep = subprocess.run(
|
||||
[REPLACE_BIN, "--no-autostart", "--keep-panels"],
|
||||
env=env, capture_output=True, text=True,
|
||||
)
|
||||
assert rep.returncode == 0, f"replace inside anode-session failed: {rep.stderr}"
|
||||
|
||||
wm2 = wait_until(
|
||||
lambda: (lambda w: w if w and w != wm1 else None)(get_win_prop_ulong(dpy, root, "_NET_SUPPORTING_WM_CHECK")),
|
||||
timeout=5.0,
|
||||
)
|
||||
assert wm2
|
||||
new_pid = get_win_prop_ulong(dpy, wm2, "_NET_WM_PID")
|
||||
assert new_pid
|
||||
|
||||
# Original anode-session must stay alive after its dwm yields with status 75
|
||||
time.sleep(0.8)
|
||||
assert sess1.poll() is None, f"anode-session exited prematurely on replacement ({sess1.returncode})"
|
||||
|
||||
# Once the replacement WM exits, the original session holder should also exit cleanly
|
||||
kill_pid_and_wait(new_pid)
|
||||
new_pid = None
|
||||
assert wait_until(lambda: sess1.poll() is not None, timeout=5.0), "anode-session did not exit after replacement WM died"
|
||||
assert sess1.returncode == 0
|
||||
finally:
|
||||
terminate(sess1)
|
||||
kill_pid_and_wait(new_pid)
|
||||
if dpy:
|
||||
X11.XCloseDisplay(dpy)
|
||||
terminate(xvfb)
|
||||
|
||||
|
||||
def compile_x11_flags():
|
||||
try:
|
||||
r = subprocess.run(
|
||||
["pkg-config", "--cflags", "--libs", "x11"],
|
||||
capture_output=True, text=True, check=True,
|
||||
)
|
||||
return r.stdout.split()
|
||||
except Exception:
|
||||
return ["-lX11"]
|
||||
|
||||
|
||||
def test_dm_session_leader_guard():
|
||||
disp = pick_display()
|
||||
cc = os.environ.get("CC", "cc")
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
env = make_env(tmp, disp)
|
||||
dm_bin = os.path.join(tmp, "bin", "lightdm")
|
||||
wm_bin = os.path.join(tmp, "bin", "mockwm_tst")
|
||||
|
||||
dm_c = os.path.join(tmp, "lightdm.c")
|
||||
with open(dm_c, "w", encoding="utf-8") as f:
|
||||
f.write(
|
||||
"#include <sys/wait.h>\n"
|
||||
"#include <unistd.h>\n"
|
||||
"int main(int argc, char **argv) {\n"
|
||||
" if (argc < 2) return 1;\n"
|
||||
" pid_t p = fork();\n"
|
||||
" if (p == 0) { execvp(argv[1], argv + 1); _exit(127); }\n"
|
||||
" int st = 0;\n"
|
||||
" waitpid(p, &st, 0);\n"
|
||||
" return WIFEXITED(st) ? WEXITSTATUS(st) : 1;\n"
|
||||
"}\n"
|
||||
)
|
||||
subprocess.run([cc, "-O2", dm_c, "-o", dm_bin], check=True)
|
||||
|
||||
wm_c = os.path.join(tmp, "mockwm_tst.c")
|
||||
with open(wm_c, "w", encoding="utf-8") as f:
|
||||
f.write(
|
||||
"#define _POSIX_C_SOURCE 200809L\n"
|
||||
"#include <signal.h>\n"
|
||||
"#include <string.h>\n"
|
||||
"#include <time.h>\n"
|
||||
"#include <unistd.h>\n"
|
||||
"#include <X11/Xatom.h>\n"
|
||||
"#include <X11/Xlib.h>\n"
|
||||
"static volatile sig_atomic_t alive = 1;\n"
|
||||
"static void stop_sig(int s) { (void)s; alive = 0; }\n"
|
||||
"int main(void) {\n"
|
||||
" signal(SIGTERM, stop_sig);\n"
|
||||
" Display *d = XOpenDisplay(NULL);\n"
|
||||
" if (!d) return 1;\n"
|
||||
" Window root = DefaultRootWindow(d);\n"
|
||||
" XSelectInput(d, root, SubstructureRedirectMask);\n"
|
||||
" Window w = XCreateSimpleWindow(d, root, 0, 0, 1, 1, 0, 0, 0);\n"
|
||||
" Atom ac = XInternAtom(d, \"_NET_SUPPORTING_WM_CHECK\", False);\n"
|
||||
" Atom an = XInternAtom(d, \"_NET_WM_NAME\", False);\n"
|
||||
" Atom au = XInternAtom(d, \"UTF8_STRING\", False);\n"
|
||||
" XChangeProperty(d, w, ac, XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1);\n"
|
||||
" XChangeProperty(d, w, an, au, 8, PropModeReplace, (unsigned char *)\"mockwm_tst\", 10);\n"
|
||||
" XChangeProperty(d, root, ac, XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1);\n"
|
||||
" XSync(d, False);\n"
|
||||
" while (alive) { struct timespec ts = {0, 100000000L}; nanosleep(&ts, NULL); }\n"
|
||||
" XDestroyWindow(d, w);\n"
|
||||
" XCloseDisplay(d);\n"
|
||||
" return 0;\n"
|
||||
"}\n"
|
||||
)
|
||||
subprocess.run([cc, "-O2", wm_c, "-o", wm_bin] + compile_x11_flags(), check=True)
|
||||
|
||||
xvfb = subprocess.Popen(
|
||||
["Xvfb", disp, "-screen", "0", "1280x720x24", "-nolisten", "tcp"],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
)
|
||||
dm_proc = None
|
||||
dpy = None
|
||||
new_pid = None
|
||||
try:
|
||||
dpy = wait_until(lambda: X11.XOpenDisplay(disp.encode()), timeout=5.0)
|
||||
assert dpy
|
||||
root = X11.XDefaultRootWindow(dpy)
|
||||
|
||||
dm_proc = subprocess.Popen([dm_bin, wm_bin], env=env)
|
||||
wm1 = wait_until(lambda: get_win_prop_ulong(dpy, root, "_NET_SUPPORTING_WM_CHECK"), timeout=5.0)
|
||||
assert wm1
|
||||
assert get_win_prop_str(dpy, wm1, "_NET_WM_NAME") == "mockwm_tst"
|
||||
assert get_win_prop_ulong(dpy, wm1, "_NET_WM_PID") is None
|
||||
|
||||
dry = subprocess.run([REPLACE_BIN, "--dry-run"], env=env, capture_output=True, text=True)
|
||||
assert dry.returncode == 0
|
||||
assert "lightdm" in dry.stdout
|
||||
assert "Warning:" in dry.stdout
|
||||
|
||||
blocked = subprocess.run(
|
||||
[REPLACE_BIN, "--no-autostart", "--keep-panels"],
|
||||
env=env, capture_output=True, text=True,
|
||||
)
|
||||
assert blocked.returncode != 0, "expected DM session-leader guard to refuse without --force"
|
||||
assert "lightdm" in blocked.stderr
|
||||
assert "--switch-session" in blocked.stderr
|
||||
assert "--force" in blocked.stderr
|
||||
assert dm_proc.poll() is None, "blocked replace must leave mock DM/WM running"
|
||||
|
||||
forced = subprocess.run(
|
||||
[REPLACE_BIN, "--force", "--no-autostart", "--keep-panels"],
|
||||
env=env, capture_output=True, text=True,
|
||||
)
|
||||
assert forced.returncode == 0, f"--force failed: stdout={forced.stdout} stderr={forced.stderr}"
|
||||
wm2 = get_win_prop_ulong(dpy, root, "_NET_SUPPORTING_WM_CHECK")
|
||||
assert wm2 and wm2 != wm1
|
||||
assert get_win_prop_str(dpy, wm2, "_NET_WM_NAME") == "ANODE WM"
|
||||
new_pid = get_win_prop_ulong(dpy, wm2, "_NET_WM_PID")
|
||||
finally:
|
||||
terminate(dm_proc)
|
||||
kill_pid_and_wait(new_pid)
|
||||
if dpy:
|
||||
X11.XCloseDisplay(dpy)
|
||||
terminate(xvfb)
|
||||
|
||||
|
||||
def test_switch_session_xprofile_handoff():
|
||||
import pwd
|
||||
|
||||
disp = pick_display()
|
||||
cc = os.environ.get("CC", "cc")
|
||||
cur_user = os.environ.get("USER") or pwd.getpwuid(os.getuid()).pw_name
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
env = make_env(tmp, disp)
|
||||
xdg_cache = os.path.join(tmp, "cache")
|
||||
env["XDG_CACHE_HOME"] = xdg_cache
|
||||
dm_bin = os.path.join(tmp, "bin", "lightdm")
|
||||
wm_bin = os.path.join(tmp, "bin", "mockwm_tst")
|
||||
|
||||
# Stub dm-tool reporting current user already has an active LightDM session
|
||||
dm_tool_stub = os.path.join(tmp, "bin", "dm-tool")
|
||||
with open(dm_tool_stub, "w", encoding="utf-8") as f:
|
||||
f.write(
|
||||
f"#!/bin/sh\n"
|
||||
f"if [ \"${{1:-}}\" = \"list-seats\" ]; then\n"
|
||||
f" printf \"Seat0\\n CanSwitch=true\\n Session0\\n UserName='%s'\\n\" '{cur_user}'\n"
|
||||
f" exit 0\n"
|
||||
f"fi\n"
|
||||
f"exit 0\n"
|
||||
)
|
||||
os.chmod(dm_tool_stub, 0o755)
|
||||
|
||||
dm_c = os.path.join(tmp, "lightdm.c")
|
||||
with open(dm_c, "w", encoding="utf-8") as f:
|
||||
f.write(
|
||||
"#include <sys/wait.h>\n"
|
||||
"#include <unistd.h>\n"
|
||||
"int main(int argc, char **argv) {\n"
|
||||
" if (argc < 2) return 1;\n"
|
||||
" pid_t p = fork();\n"
|
||||
" if (p == 0) { execvp(argv[1], argv + 1); _exit(127); }\n"
|
||||
" int st = 0;\n"
|
||||
" waitpid(p, &st, 0);\n"
|
||||
" return WIFEXITED(st) ? WEXITSTATUS(st) : 1;\n"
|
||||
"}\n"
|
||||
)
|
||||
subprocess.run([cc, "-O2", dm_c, "-o", dm_bin], check=True)
|
||||
|
||||
wm_c = os.path.join(tmp, "mockwm_tst.c")
|
||||
with open(wm_c, "w", encoding="utf-8") as f:
|
||||
f.write(
|
||||
"#define _POSIX_C_SOURCE 200809L\n"
|
||||
"#include <signal.h>\n"
|
||||
"#include <time.h>\n"
|
||||
"#include <unistd.h>\n"
|
||||
"#include <X11/Xatom.h>\n"
|
||||
"#include <X11/Xlib.h>\n"
|
||||
"static volatile sig_atomic_t alive = 1;\n"
|
||||
"static void stop_sig(int s) { (void)s; alive = 0; }\n"
|
||||
"int main(void) {\n"
|
||||
" signal(SIGTERM, stop_sig);\n"
|
||||
" Display *d = XOpenDisplay(NULL);\n"
|
||||
" if (!d) return 1;\n"
|
||||
" Window root = DefaultRootWindow(d);\n"
|
||||
" XSelectInput(d, root, SubstructureRedirectMask);\n"
|
||||
" Window w = XCreateSimpleWindow(d, root, 0, 0, 1, 1, 0, 0, 0);\n"
|
||||
" Atom ac = XInternAtom(d, \"_NET_SUPPORTING_WM_CHECK\", False);\n"
|
||||
" Atom an = XInternAtom(d, \"_NET_WM_NAME\", False);\n"
|
||||
" Atom au = XInternAtom(d, \"UTF8_STRING\", False);\n"
|
||||
" XChangeProperty(d, w, ac, XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1);\n"
|
||||
" XChangeProperty(d, w, an, au, 8, PropModeReplace, (unsigned char *)\"mockwm_tst\", 10);\n"
|
||||
" XChangeProperty(d, root, ac, XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1);\n"
|
||||
" XSync(d, False);\n"
|
||||
" while (alive) { struct timespec ts = {0, 100000000L}; nanosleep(&ts, NULL); }\n"
|
||||
" XDestroyWindow(d, w);\n"
|
||||
" XCloseDisplay(d);\n"
|
||||
" return 0;\n"
|
||||
"}\n"
|
||||
)
|
||||
subprocess.run([cc, "-O2", wm_c, "-o", wm_bin] + compile_x11_flags(), check=True)
|
||||
|
||||
xprofile = os.path.join(env["HOME"], ".xprofile")
|
||||
# Intentionally omit trailing newline to verify safe hook append
|
||||
with open(xprofile, "w", encoding="utf-8") as f:
|
||||
f.write("export USER_VAR=kept")
|
||||
|
||||
xvfb = subprocess.Popen(
|
||||
["Xvfb", disp, "-screen", "0", "1280x720x24", "-nolisten", "tcp"],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
)
|
||||
dm_proc = None
|
||||
dpy = None
|
||||
switch_file = os.path.join(xdg_cache, "anode", "switch-once")
|
||||
try:
|
||||
dpy = wait_until(lambda: X11.XOpenDisplay(disp.encode()), timeout=5.0)
|
||||
assert dpy
|
||||
root = X11.XDefaultRootWindow(dpy)
|
||||
|
||||
dm_proc = subprocess.Popen([dm_bin, wm_bin], env=env)
|
||||
assert wait_until(lambda: get_win_prop_ulong(dpy, root, "_NET_SUPPORTING_WM_CHECK"), timeout=5.0)
|
||||
|
||||
dry = subprocess.run(
|
||||
[REPLACE_BIN, "--switch-session", "--profile", "work", "--dry-run"],
|
||||
env=env, capture_output=True, text=True,
|
||||
)
|
||||
assert dry.returncode == 0, dry.stderr
|
||||
assert ".xprofile" in dry.stdout and "switch-once" in dry.stdout
|
||||
assert not os.path.exists(switch_file), "--dry-run must not write switch-once"
|
||||
with open(xprofile, "r", encoding="utf-8") as f:
|
||||
assert f.read() == "export USER_VAR=kept"
|
||||
|
||||
sw = subprocess.run(
|
||||
[REPLACE_BIN, "--switch-session", "--profile", "work"],
|
||||
env=env, capture_output=True, text=True,
|
||||
)
|
||||
assert sw.returncode == 0, f"--switch-session failed: {sw.stderr}"
|
||||
assert wait_until(lambda: dm_proc.poll() is not None, timeout=4.0), "WM did not exit for session switch"
|
||||
assert os.path.exists(switch_file), "switch-once sentinel was not created"
|
||||
|
||||
# Simulate LightDM /etc/lightdm/Xsession sourcing ~/.xprofile then running $@
|
||||
xsession_sim = os.path.join(tmp, "Xsession")
|
||||
with open(xsession_sim, "w", encoding="utf-8") as f:
|
||||
f.write("#!/bin/sh\n. \"$HOME/.xprofile\"\nprintf 'USER_VAR=%s ARGS=%s\\n' \"${USER_VAR:-}\" \"$*\"\n")
|
||||
os.chmod(xsession_sim, 0o755)
|
||||
|
||||
run1 = subprocess.run(["/bin/sh", xsession_sim, "i3"], env=env, capture_output=True, text=True, check=True)
|
||||
expected_sess = os.path.join(ROOT, "scripts", "anode-session")
|
||||
assert f"USER_VAR=kept ARGS={expected_sess} --profile work" == run1.stdout.strip(), run1.stdout
|
||||
assert not os.path.exists(switch_file), "switch-once sentinel was not consumed on login"
|
||||
|
||||
# Subsequent login must return to original default session (one-shot)
|
||||
run2 = subprocess.run(["/bin/sh", xsession_sim, "i3"], env=env, capture_output=True, text=True, check=True)
|
||||
assert "USER_VAR=kept ARGS=i3" == run2.stdout.strip(), run2.stdout
|
||||
|
||||
# Re-running --switch-session without X11 WM still running must keep hook idempotent
|
||||
sw_env = dict(env)
|
||||
sw_env.pop("DISPLAY", None)
|
||||
sw2 = subprocess.run(
|
||||
[REPLACE_BIN, "--switch-session"],
|
||||
env=sw_env, capture_output=True, text=True,
|
||||
)
|
||||
assert sw2.returncode == 0, sw2.stderr
|
||||
with open(xprofile, "r", encoding="utf-8") as f:
|
||||
xp_txt = f.read()
|
||||
assert xp_txt.count("# >>> anode-switch-once >>>") == 1, "xprofile hook was duplicated"
|
||||
assert "export USER_VAR=kept\n" in xp_txt
|
||||
finally:
|
||||
terminate(dm_proc)
|
||||
if dpy:
|
||||
X11.XCloseDisplay(dpy)
|
||||
terminate(xvfb)
|
||||
|
||||
|
||||
def test_switch_session_stale_i3sock_fallback():
|
||||
import pwd
|
||||
|
||||
disp = pick_display()
|
||||
cc = os.environ.get("CC", "cc")
|
||||
cur_user = os.environ.get("USER") or pwd.getpwuid(os.getuid()).pw_name
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
env = make_env(tmp, disp)
|
||||
env["XDG_CACHE_HOME"] = os.path.join(tmp, "cache")
|
||||
env["I3SOCK"] = "/nonexistent/i3/ipc-socket.9999"
|
||||
|
||||
dm_tool_stub = os.path.join(tmp, "bin", "dm-tool")
|
||||
with open(dm_tool_stub, "w", encoding="utf-8") as f:
|
||||
f.write(
|
||||
f"#!/bin/sh\n"
|
||||
f"if [ \"${{1:-}}\" = \"list-seats\" ]; then\n"
|
||||
f" printf \"Seat0\\n CanSwitch=true\\n Session0\\n UserName='%s'\\n\" '{cur_user}'\n"
|
||||
f"fi\nexit 0\n"
|
||||
)
|
||||
os.chmod(dm_tool_stub, 0o755)
|
||||
|
||||
seen_file = os.path.join(tmp, "i3sock_seen")
|
||||
i3_msg_stub = os.path.join(tmp, "bin", "i3-msg")
|
||||
with open(i3_msg_stub, "w", encoding="utf-8") as f:
|
||||
f.write(
|
||||
f"#!/bin/sh\n"
|
||||
f"printf '%s\\n' \"${{I3SOCK:-UNSET}}\" > '{seen_file}'\n"
|
||||
f"exit 1\n"
|
||||
)
|
||||
os.chmod(i3_msg_stub, 0o755)
|
||||
|
||||
wm_bin = os.path.join(tmp, "bin", "mock_i3")
|
||||
wm_c = os.path.join(tmp, "mock_i3.c")
|
||||
with open(wm_c, "w", encoding="utf-8") as f:
|
||||
f.write(
|
||||
"#define _POSIX_C_SOURCE 200809L\n"
|
||||
"#include <signal.h>\n"
|
||||
"#include <time.h>\n"
|
||||
"#include <unistd.h>\n"
|
||||
"#include <X11/Xatom.h>\n"
|
||||
"#include <X11/Xlib.h>\n"
|
||||
"static volatile sig_atomic_t alive = 1;\n"
|
||||
"static void stop_sig(int s) { (void)s; alive = 0; }\n"
|
||||
"int main(void) {\n"
|
||||
" signal(SIGTERM, stop_sig);\n"
|
||||
" Display *d = XOpenDisplay(NULL);\n"
|
||||
" if (!d) return 1;\n"
|
||||
" Window root = DefaultRootWindow(d);\n"
|
||||
" XSelectInput(d, root, SubstructureRedirectMask);\n"
|
||||
" Window w = XCreateSimpleWindow(d, root, 0, 0, 1, 1, 0, 0, 0);\n"
|
||||
" Atom ac = XInternAtom(d, \"_NET_SUPPORTING_WM_CHECK\", False);\n"
|
||||
" Atom an = XInternAtom(d, \"_NET_WM_NAME\", False);\n"
|
||||
" Atom ap = XInternAtom(d, \"_NET_WM_PID\", False);\n"
|
||||
" Atom au = XInternAtom(d, \"UTF8_STRING\", False);\n"
|
||||
" unsigned long pid = (unsigned long)getpid();\n"
|
||||
" XChangeProperty(d, w, ac, XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1);\n"
|
||||
" XChangeProperty(d, w, an, au, 8, PropModeReplace, (unsigned char *)\"i3\", 2);\n"
|
||||
" XChangeProperty(d, w, ap, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&pid, 1);\n"
|
||||
" XChangeProperty(d, root, ac, XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1);\n"
|
||||
" XSync(d, False);\n"
|
||||
" while (alive) { struct timespec ts = {0, 100000000L}; nanosleep(&ts, NULL); }\n"
|
||||
" XDestroyWindow(d, w);\n"
|
||||
" XCloseDisplay(d);\n"
|
||||
" return 0;\n"
|
||||
"}\n"
|
||||
)
|
||||
subprocess.run([cc, "-O2", wm_c, "-o", wm_bin] + compile_x11_flags(), check=True)
|
||||
|
||||
xvfb = subprocess.Popen(
|
||||
["Xvfb", disp, "-screen", "0", "1280x720x24", "-nolisten", "tcp"],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
)
|
||||
wm_proc = None
|
||||
dpy = None
|
||||
try:
|
||||
dpy = wait_until(lambda: X11.XOpenDisplay(disp.encode()), timeout=5.0)
|
||||
assert dpy
|
||||
root = X11.XDefaultRootWindow(dpy)
|
||||
wm_proc = subprocess.Popen([wm_bin], env=env)
|
||||
assert wait_until(lambda: get_win_prop_ulong(dpy, root, "_NET_SUPPORTING_WM_CHECK"), timeout=5.0)
|
||||
|
||||
sw = subprocess.run([REPLACE_BIN, "--switch-session"], env=env, capture_output=True, text=True)
|
||||
assert sw.returncode == 0, sw.stderr
|
||||
assert wait_until(lambda: wm_proc.poll() is not None, timeout=4.0), "PID fallback did not stop WM after i3-msg failure"
|
||||
with open(seen_file, "r", encoding="utf-8") as f:
|
||||
assert f.read().strip() == "UNSET", "anode-replace did not unset stale I3SOCK before invoking i3-msg"
|
||||
finally:
|
||||
terminate(wm_proc)
|
||||
if dpy:
|
||||
X11.XCloseDisplay(dpy)
|
||||
terminate(xvfb)
|
||||
|
||||
|
||||
def main():
|
||||
if not shutil.which("Xvfb"):
|
||||
print("test_replace: Xvfb not installed (skipping)")
|
||||
@@ -377,6 +794,10 @@ def main():
|
||||
test_fastfetch_identity()
|
||||
test_icccm_replace_and_client_preservation()
|
||||
test_non_icccm_wm_fallback_replace()
|
||||
test_anode_session_holds_open_on_replace()
|
||||
test_dm_session_leader_guard()
|
||||
test_switch_session_xprofile_handoff()
|
||||
test_switch_session_stale_i3sock_fallback()
|
||||
print("test_replace: OK")
|
||||
return 0
|
||||
|
||||
|
||||
+210
-11
@@ -34,13 +34,13 @@ def parse_xres(path):
|
||||
|
||||
def test_fractional_scales():
|
||||
scales = [
|
||||
("0.75", 72, "1", 11),
|
||||
("1.00", 96, "1", 15),
|
||||
("1.25", 120, "1", 19),
|
||||
("1.50", 144, "1", 23),
|
||||
("1.75", 168, "2", 26),
|
||||
("2.00", 192, "2", 30),
|
||||
("2.50", 240, "3", 38),
|
||||
("0.75", 72, "1", "1.0", 11, 16, 16),
|
||||
("1.00", 96, "1", "1.0", 15, 24, 24),
|
||||
("1.25", 120, "1", "1.0", 19, 24, 24),
|
||||
("1.50", 144, "1", "1.0", 23, 32, 32),
|
||||
("1.75", 168, "2", "0.5", 26, 32, 16),
|
||||
("2.00", 192, "2", "0.5", 30, 48, 24),
|
||||
("2.50", 240, "3", "0.333", 38, 48, 16),
|
||||
]
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
env = dict(os.environ)
|
||||
@@ -50,33 +50,81 @@ def test_fractional_scales():
|
||||
env["ANODE_PREFIX"] = ROOT
|
||||
env["ANODE_NO_SIGNAL"] = "1"
|
||||
|
||||
for s_str, exp_dpi, exp_gdk, exp_px in scales:
|
||||
for s_str, exp_dpi, exp_gdk, exp_gdk_dpi, exp_px, exp_cur, exp_gtk_cur in scales:
|
||||
run_env(env, [APPLY_SCALE, s_str, "--touch=1"])
|
||||
scale_env_p = os.path.join(tmp, ".config", "anode", "scale.env")
|
||||
with open(scale_env_p, "r", encoding="utf-8") as f:
|
||||
senv = f.read()
|
||||
assert f'export GDK_SCALE="{exp_gdk}"' in senv, senv
|
||||
assert 'export GDK_DPI_SCALE="1.0"' in senv, senv
|
||||
assert f'export GDK_DPI_SCALE="{exp_gdk_dpi}"' in senv, senv
|
||||
assert f'export QT_SCALE_FACTOR="{s_str}"' in senv, senv
|
||||
assert 'export QT_FONT_DPI="96"' in senv, senv
|
||||
assert 'export QT_AUTO_SCREEN_SCALE_FACTOR="0"' in senv, senv
|
||||
assert 'export QT_SCALE_FACTOR_ROUNDING_POLICY="PassThrough"' in senv, senv
|
||||
assert f'export XCURSOR_SIZE="{exp_cur}"' in senv, senv
|
||||
|
||||
scale_conf_p = os.path.join(tmp, ".config", "anode", "scale.conf")
|
||||
with open(scale_conf_p, "r", encoding="utf-8") as f:
|
||||
sconf = f.read()
|
||||
assert f"XCURSOR_SIZE={exp_cur}" in sconf, sconf
|
||||
|
||||
xres = parse_xres(os.path.join(tmp, ".Xresources"))
|
||||
assert int(xres["Xft.dpi"]) == exp_dpi, f"scale={s_str} dpi={xres['Xft.dpi']}"
|
||||
assert int(xres["theme.baseFontSize"]) == exp_px, f"scale={s_str} base={xres['theme.baseFontSize']}"
|
||||
assert int(xres["Xcursor.size"]) == exp_cur, f"scale={s_str} cur={xres['Xcursor.size']}"
|
||||
assert xres["theme.fontFace"] == "Fira Code"
|
||||
assert "Fira Code" in xres["st.font"] and f"pixelsize={exp_px}" in xres["st.font"]
|
||||
assert "Fira Code" in xres["dwm.font"] and f"{exp_px}px" in xres["dwm.font"]
|
||||
assert xres["*TkTheme"] == "gtkTtk"
|
||||
assert xres["theme.touchMode"] == "1"
|
||||
|
||||
# Verify xsettingsd omits Xft/DPI so GTK3 does not double-scale
|
||||
# Verify xsettingsd omits Xft/DPI and keeps unscaled logical pt + GDK-adjusted cursor
|
||||
xs_p = os.path.join(tmp, ".config", "xsettingsd", "xsettingsd.conf")
|
||||
with open(xs_p, "r", encoding="utf-8") as f:
|
||||
xs = f.read()
|
||||
assert "Xft/DPI" not in xs, f"Xft/DPI must not exist in xsettingsd.conf:\n{xs}"
|
||||
assert f"Gdk/WindowScalingFactor {exp_gdk}" in xs, xs
|
||||
assert 'Gtk/FontName "Fira Code 10"' in xs, xs
|
||||
assert f"Gtk/CursorThemeSize {exp_gtk_cur}" in xs, xs
|
||||
|
||||
with open(os.path.join(tmp, ".gtkrc-2.0"), "r", encoding="utf-8") as f:
|
||||
gtk2 = f.read()
|
||||
assert 'gtk-font-name="Fira Code 10"' in gtk2, gtk2
|
||||
assert f"gtk-cursor-theme-size={exp_cur}" in gtk2, gtk2
|
||||
|
||||
for gver in ("gtk-3.0", "gtk-4.0"):
|
||||
with open(os.path.join(tmp, ".config", gver, "settings.ini"), "r", encoding="utf-8") as f:
|
||||
gini = f.read()
|
||||
assert "gtk-font-name=Fira Code 10" in gini, gini
|
||||
assert f"gtk-cursor-theme-size={exp_gtk_cur}" in gini, gini
|
||||
with open(os.path.join(tmp, ".config", gver, "gtk.css"), "r", encoding="utf-8") as f:
|
||||
gcss = f.read()
|
||||
assert "@define-color" in gcss, gcss
|
||||
for bad in ("min-height:", "min-width:", "padding:", "margin:", "font-family:"):
|
||||
assert bad not in gcss, f"Unexpected {bad} in .config/{gver}/gtk.css"
|
||||
|
||||
tcss_p = os.path.join(tmp, ".themes", "ANODE-AnodeDefault", gver, "gtk.css")
|
||||
with open(tcss_p, "r", encoding="utf-8") as f:
|
||||
tcss = f.read()
|
||||
exp_imp = (
|
||||
'@import url("resource:///org/gtk/libgtk/theme/Default/Default-dark.css");'
|
||||
if gver == "gtk-4.0"
|
||||
else '@import url("resource:///org/gtk/libgtk/theme/Adwaita/gtk-contained-dark.css");'
|
||||
)
|
||||
assert tcss.splitlines()[0] == exp_imp, tcss.splitlines()[:3]
|
||||
for bad in ("min-height:", "min-width:", "padding:", "margin:", "font-family:"):
|
||||
assert bad not in tcss, f"Unexpected {bad} in theme {gver}/gtk.css"
|
||||
|
||||
for qver in ("qt5ct", "qt6ct"):
|
||||
with open(os.path.join(tmp, ".config", qver, f"{qver}.conf"), "r", encoding="utf-8") as f:
|
||||
qconf = f.read()
|
||||
assert 'general="Fira Code,10,' in qconf, qconf
|
||||
assert 'fixed="Fira Code,10,' in qconf, qconf
|
||||
|
||||
with open(os.path.join(tmp, ".config", "dunst", "dunstrc"), "r", encoding="utf-8") as f:
|
||||
drc = f.read()
|
||||
assert "scale = 1" in drc, drc
|
||||
assert f"font = Fira Code {exp_px}px" in drc, drc
|
||||
|
||||
# Verify Qt5 + Qt6 + Kvantum + Dunst + GTK2/3/4 files
|
||||
for p in [
|
||||
@@ -138,7 +186,158 @@ def test_all_22_themes_and_legacy_192dpi_import():
|
||||
assert int(xres["dwm.borderpx"]) == 2, xres["dwm.borderpx"]
|
||||
|
||||
|
||||
def test_st_overrides_and_xresources_local():
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
env = dict(os.environ)
|
||||
env.pop("DISPLAY", None)
|
||||
env["HOME"] = tmp
|
||||
env["XDG_CONFIG_HOME"] = os.path.join(tmp, ".config")
|
||||
env["ANODE_PREFIX"] = ROOT
|
||||
env["ANODE_NO_SIGNAL"] = "1"
|
||||
run_env(env, [APPLY_SCALE, "1.50", "--touch=0", "--no-apply"])
|
||||
|
||||
xres_p = os.path.join(tmp, ".Xresources")
|
||||
with open(xres_p, "w", encoding="utf-8") as f:
|
||||
f.write("St.font: Fira Code:size=14:antialias=true:autohint=true\n")
|
||||
f.write("St.alpha: 0.95\n")
|
||||
|
||||
# Repeated theme applications must preserve St.* cleanly without duplication
|
||||
run_env(env, [APPLY_THEME, "AnodeDefault"])
|
||||
run_env(env, [APPLY_THEME, "AnodeDefault"])
|
||||
with open(xres_p, "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
assert content.count("St.font:") == 1, content
|
||||
assert content.count("St.alpha:") == 1, content
|
||||
assert "St.font: Fira Code:size=14:antialias=true:autohint=true" in content, content
|
||||
|
||||
# Adding Xresources.local must replace duplicate keys from preserved section and persist
|
||||
local_p = os.path.join(tmp, ".config", "anode", "Xresources.local")
|
||||
with open(local_p, "w", encoding="utf-8") as f:
|
||||
f.write("St.font: Fira Code:size=16:antialias=true\n")
|
||||
f.write("*.cursorBlink: true\n")
|
||||
|
||||
run_env(env, [APPLY_THEME, "AnodeDefault"])
|
||||
run_env(env, [APPLY_THEME, "AnodeDefault"])
|
||||
with open(xres_p, "r", encoding="utf-8") as f:
|
||||
content2 = f.read()
|
||||
assert content2.count("St.font:") == 1, content2
|
||||
assert content2.count("St.alpha:") == 1, content2
|
||||
assert content2.count("*.cursorBlink:") == 1, content2
|
||||
assert "St.font: Fira Code:size=16:antialias=true" in content2, content2
|
||||
|
||||
|
||||
def test_auto_scale_honors_explicit_server_dpi():
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
fbin = os.path.join(tmp, "bin")
|
||||
os.makedirs(fbin)
|
||||
xdpy_p = os.path.join(fbin, "xdpyinfo")
|
||||
xrandr_p = os.path.join(fbin, "xrandr")
|
||||
with open(xdpy_p, "w", encoding="utf-8") as f:
|
||||
f.write("#!/bin/sh\necho ' dimensions: 1920x1200 pixels (338x211 millimeters)'\necho ' resolution: 144x144 dots per inch'\n")
|
||||
with open(xrandr_p, "w", encoding="utf-8") as f:
|
||||
f.write("#!/bin/sh\necho 'eDP connected primary 1920x1200+0+0 (normal left inverted right x axis y axis) 301mm x 188mm'\n")
|
||||
os.chmod(xdpy_p, 0o755)
|
||||
os.chmod(xrandr_p, 0o755)
|
||||
|
||||
env = dict(os.environ)
|
||||
env["DISPLAY"] = ":99"
|
||||
env["HOME"] = tmp
|
||||
env["XDG_CONFIG_HOME"] = os.path.join(tmp, ".config")
|
||||
env["ANODE_PREFIX"] = ROOT
|
||||
env["ANODE_NO_SIGNAL"] = "1"
|
||||
env["PATH"] = fbin + ":" + env.get("PATH", "")
|
||||
|
||||
run_env(env, [APPLY_SCALE, "auto", "--no-apply"])
|
||||
with open(os.path.join(tmp, ".config", "anode", "scale.conf"), "r", encoding="utf-8") as f:
|
||||
sconf = f.read()
|
||||
assert "SCALE=1.50" in sconf, sconf
|
||||
assert "XCURSOR_SIZE=32" in sconf, sconf
|
||||
|
||||
|
||||
def test_stale_env_does_not_override_scale_conf():
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
env = dict(os.environ)
|
||||
env.pop("DISPLAY", None)
|
||||
env["HOME"] = tmp
|
||||
env["XDG_CONFIG_HOME"] = os.path.join(tmp, ".config")
|
||||
env["ANODE_PREFIX"] = ROOT
|
||||
env["ANODE_NO_SIGNAL"] = "1"
|
||||
env["ANODE_NO_DBUS"] = "1"
|
||||
|
||||
run_env(env, [APPLY_SCALE, "2.00", "--touch=1"])
|
||||
|
||||
stale_env = dict(env)
|
||||
stale_env["ANODE_SCALE"] = "2.00"
|
||||
stale_env["ANODE_TOUCH"] = "1"
|
||||
run_env(stale_env, [APPLY_SCALE, "1.25", "--touch=0"])
|
||||
|
||||
with open(os.path.join(tmp, ".config", "anode", "scale.conf"), "r", encoding="utf-8") as f:
|
||||
sconf = f.read()
|
||||
assert "SCALE=1.25" in sconf and "TOUCH=0" in sconf, sconf
|
||||
|
||||
with open(os.path.join(tmp, ".config", "anode", "scale.env"), "r", encoding="utf-8") as f:
|
||||
senv = f.read()
|
||||
assert 'export ANODE_SCALE="1.25"' in senv and 'export ANODE_TOUCH="0"' in senv, senv
|
||||
|
||||
xres = parse_xres(os.path.join(tmp, ".Xresources"))
|
||||
assert xres["theme.scale"] == "1.25", xres["theme.scale"]
|
||||
assert xres["Xft.dpi"] == "120", xres["Xft.dpi"]
|
||||
assert xres["theme.touchMode"] == "0", xres["theme.touchMode"]
|
||||
|
||||
with open(os.path.join(tmp, ".config", "dunst", "dunstrc"), "r", encoding="utf-8") as f:
|
||||
assert "font = Fira Code 19px" in f.read()
|
||||
with open(os.path.join(tmp, ".config", "gtk-3.0", "settings.ini"), "r", encoding="utf-8") as f:
|
||||
assert "gtk-cursor-theme-size=24" in f.read()
|
||||
|
||||
# Re-applying theme with stale ANODE_SCALE/ANODE_TOUCH still honors scale.conf
|
||||
run_env(stale_env, [APPLY_THEME, "AnodeDefault"])
|
||||
xres2 = parse_xres(os.path.join(tmp, ".Xresources"))
|
||||
assert xres2["theme.scale"] == "1.25" and xres2["Xft.dpi"] == "120" and xres2["theme.touchMode"] == "0"
|
||||
|
||||
|
||||
def test_gtk_theme_light_dark_detection_and_css_parse():
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
env = dict(os.environ)
|
||||
env.pop("DISPLAY", None)
|
||||
env["HOME"] = tmp
|
||||
env["XDG_CONFIG_HOME"] = os.path.join(tmp, ".config")
|
||||
env["ANODE_PREFIX"] = ROOT
|
||||
env["ANODE_NO_SIGNAL"] = "1"
|
||||
run_env(env, [APPLY_SCALE, "1.25", "--touch=0", "--no-apply"])
|
||||
|
||||
for light_th in ("CatppuccinLatte", "GruvboxLight", "SolarizedLight"):
|
||||
run_env(env, [APPLY_THEME, light_th])
|
||||
with open(os.path.join(tmp, ".config", "gtk-3.0", "settings.ini"), "r", encoding="utf-8") as f:
|
||||
assert "gtk-application-prefer-dark-theme=0" in f.read()
|
||||
t3 = os.path.join(tmp, ".themes", f"ANODE-{light_th}", "gtk-3.0", "gtk.css")
|
||||
t4 = os.path.join(tmp, ".themes", f"ANODE-{light_th}", "gtk-4.0", "gtk.css")
|
||||
with open(t3, "r", encoding="utf-8") as f:
|
||||
txt3 = f.read()
|
||||
with open(t4, "r", encoding="utf-8") as f:
|
||||
txt4 = f.read()
|
||||
assert txt3.splitlines()[0] == '@import url("resource:///org/gtk/libgtk/theme/Adwaita/gtk-contained.css");'
|
||||
assert txt4.splitlines()[0] == '@import url("resource:///org/gtk/libgtk/theme/Default/Default-light.css");'
|
||||
|
||||
run_env(env, [APPLY_THEME, "AnodeDefault"])
|
||||
t3_dark = os.path.join(tmp, ".themes", "ANODE-AnodeDefault", "gtk-3.0", "gtk.css")
|
||||
try:
|
||||
import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
prov = Gtk.CssProvider()
|
||||
errs = []
|
||||
prov.connect("parsing-error", lambda p, s, e: errs.append(str(e)))
|
||||
prov.load_from_path(t3_dark)
|
||||
assert not errs, f"GTK3 CSS parse errors: {errs}"
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_fractional_scales()
|
||||
test_all_22_themes_and_legacy_192dpi_import()
|
||||
print("test_theme_scale: ALL PASSED (7 fractional scales, 22 themes, legacy 192-DPI import)")
|
||||
test_st_overrides_and_xresources_local()
|
||||
test_auto_scale_honors_explicit_server_dpi()
|
||||
test_stale_env_does_not_override_scale_conf()
|
||||
test_gtk_theme_light_dark_detection_and_css_parse()
|
||||
print("test_theme_scale: ALL PASSED (7 fractional scales, 22 themes, legacy 192-DPI import, St overrides, auto DPI, scale.conf precedence, GTK light/dark)")
|
||||
+57
-3
@@ -13,6 +13,7 @@
|
||||
#include "anode_bt_list.h"
|
||||
#include "anode_power_policy.h"
|
||||
#include "anode_xkb_parse.h"
|
||||
#include "anode_sys_parse.h"
|
||||
#include "anode-touch-gesture.h"
|
||||
|
||||
static void test_scale_math(void) {
|
||||
@@ -152,16 +153,20 @@ static void test_power_policy_and_gestures(void) {
|
||||
anode_power_policy_step(&cfg, &st, 10000, false, 80, true, false, &act);
|
||||
assert(st == ANODE_PWR_ACTIVE && !act.dim_now);
|
||||
|
||||
anode_power_policy_step(&cfg, &st, 65000, false, 80, true, false, &act);
|
||||
anode_power_policy_step(&cfg, &st, 305000, false, 80, true, false, &act);
|
||||
assert(st == ANODE_PWR_DIMMED && act.dim_now);
|
||||
|
||||
anode_power_policy_step(&cfg, &st, 1000, false, 80, true, false, &act);
|
||||
assert(st == ANODE_PWR_ACTIVE && act.restore_brightness);
|
||||
|
||||
anode_power_policy_step(&cfg, &st, 190000, false, 80, true, false, &act);
|
||||
anode_power_policy_step(&cfg, &st, 610000, false, 80, true, false, &act);
|
||||
assert(st == ANODE_PWR_LOCKED && act.lock_now);
|
||||
|
||||
anode_power_policy_step(&cfg, &st, 610000, false, 80, true, true, &act);
|
||||
/* Waking from ANODE_PWR_LOCKED must also restore dimmed brightness */
|
||||
anode_power_policy_step(&cfg, &st, 1000, false, 80, true, false, &act);
|
||||
assert(st == ANODE_PWR_ACTIVE && act.restore_brightness);
|
||||
|
||||
anode_power_policy_step(&cfg, &st, 1810000, false, 80, true, true, &act);
|
||||
assert(st == ANODE_PWR_SUSPENDED && act.suspend_now);
|
||||
|
||||
/* Critical low battery override on battery */
|
||||
@@ -225,6 +230,45 @@ static void test_xkb_layout_parser(void) {
|
||||
assert(!anode_xkb_layout_from_group_name("!!!", buf, sizeof(buf)));
|
||||
}
|
||||
|
||||
static void test_sys_parsers(void) {
|
||||
anode_cpu_sample_t prev = {0, 0}, cur = {0, 0};
|
||||
const char *stat1 =
|
||||
"cpu 100 0 50 850 0 0 0 0 0 0\n"
|
||||
"cpu0 50 0 25 425 0 0 0 0 0 0\n";
|
||||
const char *stat_25 =
|
||||
"cpu 300 0 100 1550 50 0 0 0 0 0\n"
|
||||
"cpu0 150 0 50 775 25 0 0 0 0 0\n";
|
||||
const char *stat_idle = "cpu 300 0 100 2550 50 0 0 0 0 0\n";
|
||||
const char *stat_full = "cpu 1300 0 100 2550 50 0 0 0 0 0\n";
|
||||
|
||||
assert(anode_parse_proc_stat_cpu(stat1, &prev));
|
||||
assert(prev.total == 1000 && prev.idle == 850);
|
||||
assert(anode_parse_proc_stat_cpu(stat_25, &cur));
|
||||
assert(cur.total == 2000 && cur.idle == 1600);
|
||||
assert(anode_cpu_usage_pct(&prev, &cur) == 25);
|
||||
assert(anode_cpu_usage_pct(&cur, &cur) == 0);
|
||||
assert(anode_cpu_usage_pct(&cur, &prev) == 0);
|
||||
|
||||
anode_cpu_sample_t idle_s = {0, 0}, full_s = {0, 0};
|
||||
assert(anode_parse_proc_stat_cpu(stat_idle, &idle_s));
|
||||
assert(anode_cpu_usage_pct(&cur, &idle_s) == 0);
|
||||
assert(anode_parse_proc_stat_cpu(stat_full, &full_s));
|
||||
assert(anode_cpu_usage_pct(&idle_s, &full_s) == 100);
|
||||
assert(!anode_parse_proc_stat_cpu("intr 1 2 3\n", &cur));
|
||||
assert(!anode_parse_proc_stat_cpu("cpu 10 20\n", &cur));
|
||||
|
||||
int ram = -1;
|
||||
assert(anode_parse_proc_meminfo_pct(
|
||||
"MemTotal: 1000000 kB\nMemFree: 100000 kB\nMemAvailable: 250000 kB\n", &ram));
|
||||
assert(ram == 75);
|
||||
assert(anode_parse_proc_meminfo_pct(
|
||||
"MemTotal: 1000000 kB\nMemFree: 100000 kB\nBuffers: 100000 kB\n"
|
||||
"Cached: 300000 kB\nSReclaimable: 100000 kB\n", &ram));
|
||||
assert(ram == 40);
|
||||
assert(!anode_parse_proc_meminfo_pct("MemFree: 100 kB\n", &ram));
|
||||
assert(!anode_parse_proc_meminfo_pct("MemTotal: 0 kB\nMemFree: 0 kB\n", &ram));
|
||||
}
|
||||
|
||||
static void test_platform_probe(void) {
|
||||
anode_net_iface_t ifs[ANODE_MAX_IFACES];
|
||||
int n = anode_list_net_ifaces(ifs, ANODE_MAX_IFACES);
|
||||
@@ -232,6 +276,15 @@ static void test_platform_probe(void) {
|
||||
anode_battery_info_t bat;
|
||||
anode_read_battery(&bat);
|
||||
(void)anode_detect_audio_backend();
|
||||
anode_cpu_sample_t cpu = {0, 0};
|
||||
int ram_pct = -1;
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
|
||||
assert(anode_read_cpu_sample(&cpu) && cpu.total > 0);
|
||||
assert(anode_read_mem_usage_pct(&ram_pct) && ram_pct >= 0 && ram_pct <= 100);
|
||||
#else
|
||||
(void)anode_read_cpu_sample(&cpu);
|
||||
(void)anode_read_mem_usage_pct(&ram_pct);
|
||||
#endif
|
||||
char buf[256];
|
||||
anode_runtime_dir(buf, sizeof(buf));
|
||||
assert(buf[0] == '/');
|
||||
@@ -247,6 +300,7 @@ int main(void) {
|
||||
test_wifi_and_bt_parsers();
|
||||
test_power_policy_and_gestures();
|
||||
test_xkb_layout_parser();
|
||||
test_sys_parsers();
|
||||
test_platform_probe();
|
||||
printf("test_units: ALL PASSED\n");
|
||||
return 0;
|
||||
|
||||
+152
-1
@@ -253,6 +253,20 @@ def test_resolution(res_str, scale_str, width, height):
|
||||
time.sleep(0.25)
|
||||
X11.XGetWindowAttributes(dpy, tray_win, ctypes.byref(tray_attr))
|
||||
assert tray_attr.height >= pre_h, f"Tray height did not preserve/scale after SIGUSR1: {tray_attr.height} vs {pre_h}"
|
||||
|
||||
# Stale exported ANODE_SCALE must not block live scale updates + SIGUSR1 reload
|
||||
stale_env = dict(env)
|
||||
stale_env["ANODE_SCALE"] = "2.00"
|
||||
stale_env["ANODE_TOUCH"] = "1"
|
||||
stale_env["ANODE_NO_DBUS"] = "1"
|
||||
subprocess.run([os.path.join(ROOT, "scripts", "anode-apply-scale"), "1.25", "--touch=0"], env=stale_env, check=True)
|
||||
if shutil.which("xrdb"):
|
||||
xq = subprocess.check_output(["xrdb", "-query"], env=env, text=True)
|
||||
assert "theme.scale:\t1.25" in xq or "theme.scale: 1.25" in xq, xq
|
||||
dwm.send_signal(signal.SIGUSR1)
|
||||
time.sleep(0.2)
|
||||
assert dwm.poll() is None, "dwm exited after SIGUSR1 live scale update"
|
||||
|
||||
subprocess.run([os.path.join(ROOT, "scripts", "anode-apply-scale"), scale_str, "--touch=1"], env=env, check=True)
|
||||
dwm.send_signal(signal.SIGUSR1)
|
||||
time.sleep(0.2)
|
||||
@@ -273,7 +287,7 @@ def test_resolution(res_str, scale_str, width, height):
|
||||
assert wait_until(lambda: (lambda w: w if w and len(w) >= 4 and w[3] < wa0[3] else None)(get_cardinal_prop(dpy, root, "_NET_WORKAREA"))), "Workarea did not re-reserve on vkbd show"
|
||||
terminate(vkbd)
|
||||
|
||||
# Test anode-statusd updates root WM_NAME and tracks XKB layout left of datetime
|
||||
# Test anode-statusd publishes CPU/RAM (never net/docker0) and lowercase XKB left of datetime
|
||||
sd = subprocess.Popen([os.path.join(BUILD, "daemons", "anode-statusd")], env=env)
|
||||
procs.append(sd)
|
||||
|
||||
@@ -290,9 +304,14 @@ def test_resolution(res_str, scale_str, width, height):
|
||||
s = get_status()
|
||||
if not s:
|
||||
return None
|
||||
assert "NET " not in s and "docker" not in s.lower(), f"Unexpected network segment in status: {s!r}"
|
||||
parts = [p.strip() for p in s.split("|")]
|
||||
if len(parts) < 4:
|
||||
return None
|
||||
if not any(re.fullmatch(r"CPU \d+%", p) for p in parts):
|
||||
return None
|
||||
if not any(re.fullmatch(r"RAM \d+%", p) for p in parts):
|
||||
return None
|
||||
if not re.fullmatch(r"\d{4}-\d{2}-\d{2} \d{2}:\d{2}", parts[-1]):
|
||||
return None
|
||||
kbd = parts[-2]
|
||||
@@ -319,6 +338,43 @@ def test_resolution(res_str, scale_str, width, height):
|
||||
assert wait_until(lambda: get_kbd_left_of_dt() == "us"), f"Expected 'us' restore: {get_status()!r}"
|
||||
terminate(sd)
|
||||
|
||||
# Test dmenu -l 0 (fills full screen height) vs dmenu -l 5 (exact list height)
|
||||
dm_full = subprocess.Popen(
|
||||
[os.path.join(BUILD, "dmenu", "dmenu"), "-l", "0"],
|
||||
env=env, stdin=subprocess.PIPE, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
)
|
||||
procs.append(dm_full)
|
||||
dm_full.stdin.write(b"\n".join(f"item{i}".encode() for i in range(60)) + b"\n")
|
||||
dm_full.stdin.close()
|
||||
def find_win_with_height(target_min_w, check_fn):
|
||||
for w in query_children(dpy, root):
|
||||
a = XWindowAttributes()
|
||||
if X11.XGetWindowAttributes(dpy, w, ctypes.byref(a)) and a.map_state == 2 and a.width >= target_min_w:
|
||||
if check_fn(a.height):
|
||||
return a.height
|
||||
return None
|
||||
h_full = wait_until(lambda: find_win_with_height(width - 10, lambda hh: hh == height))
|
||||
assert h_full == height, f"dmenu -l 0 did not fill screen height {height}: got {h_full}"
|
||||
terminate(dm_full)
|
||||
|
||||
dm_five = subprocess.Popen(
|
||||
[os.path.join(BUILD, "dmenu", "dmenu"), "-l", "5"],
|
||||
env=env, stdin=subprocess.PIPE, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
)
|
||||
procs.append(dm_five)
|
||||
dm_five.stdin.write(b"\n".join(f"item{i}".encode() for i in range(60)) + b"\n")
|
||||
dm_five.stdin.close()
|
||||
h_five = wait_until(lambda: find_win_with_height(width - 10, lambda hh: 100 <= hh < height))
|
||||
assert h_five and h_five < height, f"dmenu -l 5 height invalid: {h_five} vs {height}"
|
||||
terminate(dm_five)
|
||||
|
||||
# Test anode-checkpw rejects wrong password cleanly
|
||||
chk = subprocess.run(
|
||||
[os.path.join(BUILD, "daemons", "anode-checkpw")],
|
||||
input="definitely_wrong_pw_12345\n", env=env, capture_output=True, text=True, timeout=3,
|
||||
)
|
||||
assert chk.returncode != 0
|
||||
|
||||
# Test core + GemUI utilities launch, map cleanly inside screen, and exit cleanly
|
||||
for bin_path, extra_stdin in [
|
||||
(os.path.join(BUILD, "st", "st"), None),
|
||||
@@ -350,6 +406,99 @@ def test_resolution(res_str, scale_str, width, height):
|
||||
terminate(xvfb)
|
||||
|
||||
|
||||
def test_st_font_override_and_dunst():
|
||||
disp = pick_display()
|
||||
with tempfile.TemporaryDirectory() as home:
|
||||
env = dict(os.environ)
|
||||
env["DISPLAY"] = disp
|
||||
env["HOME"] = home
|
||||
env["XDG_CONFIG_HOME"] = os.path.join(home, ".config")
|
||||
env["ANODE_PREFIX"] = ROOT
|
||||
env["ANODE_NO_SIGNAL"] = "1"
|
||||
env["LD_LIBRARY_PATH"] = os.path.join(BUILD, "libgemui") + (":" + env["LD_LIBRARY_PATH"] if env.get("LD_LIBRARY_PATH") else "")
|
||||
env["PATH"] = (
|
||||
os.path.join(BUILD, "dwm") + ":" +
|
||||
os.path.join(BUILD, "st") + ":" +
|
||||
os.path.join(ROOT, "scripts") + ":" +
|
||||
env.get("PATH", "")
|
||||
)
|
||||
|
||||
xvfb = subprocess.Popen(
|
||||
["Xvfb", disp, "-screen", "0", "1920x1200x24", "-nolisten", "tcp"],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
)
|
||||
dpy = None
|
||||
procs = []
|
||||
try:
|
||||
dpy = wait_until(lambda: X11.XOpenDisplay(disp.encode()))
|
||||
assert dpy, f"Failed to open Xvfb {disp}"
|
||||
root = X11.XDefaultRootWindow(dpy)
|
||||
|
||||
def launch_st_and_get_height_inc(xres_text):
|
||||
xr_path = os.path.join(home, ".Xresources")
|
||||
with open(xr_path, "w", encoding="utf-8") as f:
|
||||
f.write(xres_text)
|
||||
if shutil.which("xrdb"):
|
||||
subprocess.run(["xrdb", "-load", xr_path], env=env, check=True)
|
||||
before = set(query_children(dpy, root))
|
||||
stp = subprocess.Popen(
|
||||
[os.path.join(BUILD, "st", "st"), "-e", "sh", "-c", "sleep 4"],
|
||||
env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
)
|
||||
procs.append(stp)
|
||||
|
||||
def get_inc():
|
||||
for w in query_children(dpy, root):
|
||||
if w in before:
|
||||
continue
|
||||
a = XWindowAttributes()
|
||||
if X11.XGetWindowAttributes(dpy, w, ctypes.byref(a)) and a.map_state == 2:
|
||||
out = subprocess.check_output(["xprop", "-id", hex(w), "WM_NORMAL_HINTS"], env=env, text=True)
|
||||
m = re.search(r"resize increment:\s*\d+\s+by\s+(\d+)", out)
|
||||
if m:
|
||||
return int(m.group(1))
|
||||
return None
|
||||
|
||||
inc = wait_until(get_inc)
|
||||
terminate(stp)
|
||||
procs.remove(stp)
|
||||
return inc
|
||||
|
||||
if shutil.which("xprop"):
|
||||
inc_small = launch_st_and_get_height_inc(
|
||||
"Xft.dpi: 144\nst.font: Fira Code:pixelsize=15:style=Regular:antialias=true:autohint=true\n"
|
||||
)
|
||||
assert inc_small and inc_small <= 22, f"Expected pixelsize=15 height_inc <= 22, got {inc_small}"
|
||||
|
||||
inc_override = launch_st_and_get_height_inc(
|
||||
"Xft.dpi: 144\nst.font: Fira Code:pixelsize=15:style=Regular:antialias=true:autohint=true\n"
|
||||
"St.font: Fira Code:size=14:antialias=true:autohint=true\n"
|
||||
)
|
||||
assert inc_override and inc_override >= 32, f"Expected St.font size=14 @ 144 DPI height_inc >= 32, got {inc_override}"
|
||||
|
||||
subprocess.run([os.path.join(ROOT, "scripts", "anode-apply-scale"), "1.50", "--touch=0"], env=env, check=True)
|
||||
dunstrc = os.path.join(home, ".config", "dunst", "dunstrc")
|
||||
if shutil.which("dunst"):
|
||||
denv = dict(env)
|
||||
denv.pop("DBUS_SESSION_BUS_ADDRESS", None)
|
||||
dp = subprocess.Popen(
|
||||
["dunst", "-conf", dunstrc, "-verbosity", "debug"],
|
||||
env=denv, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True,
|
||||
)
|
||||
time.sleep(0.4)
|
||||
terminate(dp)
|
||||
dout, derr = dp.communicate(timeout=3)
|
||||
combined = dout + "\n" + derr
|
||||
assert "Trying to set scale to 1" in combined, combined
|
||||
assert "Fira Code 23px" in combined, combined
|
||||
finally:
|
||||
for p in reversed(procs):
|
||||
terminate(p)
|
||||
if dpy:
|
||||
X11.XCloseDisplay(dpy)
|
||||
terminate(xvfb)
|
||||
|
||||
|
||||
def main():
|
||||
if not shutil.which("Xvfb"):
|
||||
print("test_x11_xvfb: Xvfb not installed (skipping)")
|
||||
@@ -362,6 +511,8 @@ def main():
|
||||
for res, sc, w, h in cases:
|
||||
test_resolution(res, sc, w, h)
|
||||
print(f"test_x11_xvfb: {res} @ {sc}x OK")
|
||||
test_st_font_override_and_dunst()
|
||||
print("test_x11_xvfb: St.font override & Dunst scale=1 OK")
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user