idle: retry suspend when a logind sleep inhibitor is released (#3866)

This commit is contained in:
Guillem CANAL
2026-10-22 17:12:36 -04:00
committed by GitHub
parent 900e6110d9
commit 668dde2a33
+30
View File
@@ -67,6 +67,12 @@ Singleton {
property bool isShellLocked: false
property bool isSessionLockSecure: false
property bool lockPowerOffRequested: false
property bool sleepBlocked: false
function _updateSleepBlocked(blockInhibited) {
if (typeof blockInhibited === "string")
sleepBlocked = blockInhibited.split(":").includes("sleep");
}
function reapplyDpmsIfNeeded() {
if (monitorsOff)
@@ -170,6 +176,22 @@ Singleton {
}
}
Connections {
target: DMSService
function onCapabilitiesReceived() {
if (!DMSService.capabilities.includes("dbus"))
return;
DMSService.dbusSubscribe("system", "org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.DBus.Properties", "PropertiesChanged");
DMSService.dbusGetProperty("system", "org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", "BlockInhibited", r => root._updateSleepBlocked(r.result?.value));
}
function onDbusSignalReceived(subscriptionId, data) {
if (data.path === "/org/freedesktop/login1")
root._updateSleepBlocked(data.body?.[1]?.BlockInhibited);
}
}
Connections {
target: root
function onRequestMonitorOff() {
@@ -197,5 +219,13 @@ Singleton {
_rearmIdleMonitors();
}
onSleepBlockedChanged: {
log.info(sleepBlocked ? "Sleep blocked by logind inhibitor" : "Sleep inhibitor released");
if (sleepBlocked || !suspendMonitor.enabled || !suspendMonitor.isIdle)
return;
log.info("Sleep inhibitor released while idle, retrying suspend");
requestSuspend();
}
Component.onCompleted: _applyMonitorEnableds()
}