From dd668469d7e628d651755b34d46e0fd5921b057a Mon Sep 17 00:00:00 2001 From: ksp-apoc Date: Mon, 4 May 2026 00:45:04 +0800 Subject: [PATCH] fix: clean up orphaned idle inhibitor processes on startup (#2324) When quickshell crashes or is force-killed, the child systemd-inhibit process (used as fallback when native IdleInhibitor is unavailable) gets reparented to PID 1 and continues to block idle indefinitely. This causes hypridle to ignore all idle timeout rules even though the idle inhibitor widget appears inactive after restart. Add a cleanup step during initialization that kills any orphaned systemd-inhibit processes from previous sessions. --- quickshell/Services/SessionService.qml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/quickshell/Services/SessionService.qml b/quickshell/Services/SessionService.qml index 74473499..160a4f11 100644 --- a/quickshell/Services/SessionService.qml +++ b/quickshell/Services/SessionService.qml @@ -66,6 +66,7 @@ Singleton { detectHibernateProcess.running = true; detectPrimeRunProcess.running = true; detectWtypeProcess.running = true; + cleanupOrphanedInhibitors(); log.info("Native inhibitor available:", nativeInhibitorAvailable); if (!SettingsData.loginctlLockIntegration) { log.debug("loginctl lock integration disabled by user"); @@ -462,6 +463,26 @@ Singleton { } } + // Kill orphaned idle inhibitor processes left behind by previous quickshell sessions. + // When quickshell crashes or is force-killed, the child systemd-inhibit process gets + // reparented to PID 1 and continues to block idle indefinitely. + function cleanupOrphanedInhibitors() { + if (nativeInhibitorAvailable) return; + orphanCleanupProcess.running = true; + } + + Process { + id: orphanCleanupProcess + running: false + command: ["pkill", "-f", "systemd-inhibit --what=idle --who=quickshell.*sleep infinity"] + + onExited: function (exitCode) { + if (exitCode === 0) { + log.info("Cleaned up orphaned idle inhibitor process(es) from a previous session"); + } + } + } + Connections { target: DMSService