From 17978500e4ef159245b9758f24275cf3a06082d7 Mon Sep 17 00:00:00 2001 From: VallierDev <24893073+VallierDev@users.noreply.github.com> Date: Thu, 15 Oct 2026 01:34:44 +0800 Subject: [PATCH] Add timed VM-only idle inhibition for active long-connection acceptance --- tests/fixtures/idle-inhibit.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/fixtures/idle-inhibit.py diff --git a/tests/fixtures/idle-inhibit.py b/tests/fixtures/idle-inhibit.py new file mode 100644 index 0000000..494524c --- /dev/null +++ b/tests/fixtures/idle-inhibit.py @@ -0,0 +1,21 @@ +"""Hold an ephemeral idle inhibition only in the isolated QEMU acceptance VM.""" +import pathlib,subprocess,signal,threading,sys +assert pathlib.Path('/proc/sys/kernel/hostname').read_text().strip()=='uu-hyprland-test' +assert subprocess.check_output(['systemd-detect-virt'],text=True).strip()=='qemu' +import gi +gi.require_version('Gio','2.0') +from gi.repository import Gio,GLib +seconds=min(4200,max(1,int(sys.argv[1]) if len(sys.argv)>1 else 3600)) +bus=Gio.bus_get_sync(Gio.BusType.SESSION,None) +reply=bus.call_sync('org.freedesktop.ScreenSaver','/ScreenSaver','org.freedesktop.ScreenSaver','Inhibit',GLib.Variant('(ss)',('UU isolated acceptance','Timed live-connection acceptance')),GLib.VariantType.new('(u)'),Gio.DBusCallFlags.NONE,3000,None) +cookie=reply.unpack()[0] +stop=threading.Event() +signal.signal(signal.SIGTERM,lambda *_:stop.set()) +signal.signal(signal.SIGINT,lambda *_:stop.set()) +print('VM timed idle inhibition acquired',flush=True) +try:stop.wait(seconds) +finally: + try: + bus.call_sync('org.freedesktop.ScreenSaver','/ScreenSaver','org.freedesktop.ScreenSaver','UnInhibit',GLib.Variant('(u)',(cookie,)),None,Gio.DBusCallFlags.NONE,3000,None) + print('VM timed idle inhibition released',flush=True) + except GLib.Error:print('VM idle inhibition connection closed',flush=True)