]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: when we need to execute a sleep operation we don't support, fall back to...
authorLennart Poettering <lennart@poettering.net>
Fri, 16 Nov 2018 20:44:36 +0000 (21:44 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 16 Nov 2018 20:50:24 +0000 (21:50 +0100)
If suspend-then-hibernate, hybrid-sleep or plain hibernation is
supposed to be execute due to a key press/lid switch but is not
supported, automatically fall back to plain suspend (and log about it).

Fixes: #10558
src/login/logind-action.c

index 317e9ef384ca062f3e0e343c45afd50b47743306..be5804bff1f294f6e7bed379d20eda052c3a4e60 100644 (file)
@@ -108,6 +108,14 @@ int manager_handle_action(
         else
                 supported = true;
 
+        if (!supported && IN_SET(handle, HANDLE_HIBERNATE, HANDLE_HYBRID_SLEEP, HANDLE_SUSPEND_THEN_HIBERNATE)) {
+                supported = can_sleep("suspend") > 0;
+                if (supported) {
+                        log_notice("Operation '%s' requested but not supported, using regular suspend instead.", handle_action_to_string(handle));
+                        handle = HANDLE_SUSPEND;
+                }
+        }
+
         if (!supported) {
                 log_warning("Requested operation not supported, ignoring.");
                 return -EOPNOTSUPP;