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