]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #10814 from poettering/logind-suspend-fallback
authorLennart Poettering <lennart@poettering.net>
Mon, 19 Nov 2018 10:05:48 +0000 (11:05 +0100)
committerGitHub <noreply@github.com>
Mon, 19 Nov 2018 10:05:48 +0000 (11:05 +0100)
if we need to hibernate/suspend-then-hibernate/hybrid-sleep due to keypress/lid switch but can't, fallback to regular suspend

src/login/logind-action.c

index 317e9ef384ca062f3e0e343c45afd50b47743306..e4e6c9019117088dd945965bc5eca3d696b901c3 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;
@@ -129,7 +137,7 @@ int manager_handle_action(
             manager_is_inhibited(m, inhibit_operation, INHIBIT_BLOCK, NULL, false, false, 0, &offending)) {
                 _cleanup_free_ char *comm = NULL, *u = NULL;
 
-                get_process_comm(offending->pid, &comm);
+                (void) get_process_comm(offending->pid, &comm);
                 u = uid_to_name(offending->uid);
 
                 /* If this is just a recheck of the lid switch then don't warn about anything */