summaryrefslogtreecommitdiff
path: root/src/login/logind-action.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/login/logind-action.c')
-rw-r--r--src/login/logind-action.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/login/logind-action.c b/src/login/logind-action.c
index 08e41af81a..e4e6c90191 100644
--- a/src/login/logind-action.c
+++ b/src/login/logind-action.c
@@ -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 */
@@ -152,10 +160,8 @@ int manager_handle_action(
log_info("%s", message_table[handle]);
r = bus_manager_shutdown_or_sleep_now_or_later(m, target, inhibit_operation, &error);
- if (r < 0) {
- log_error("Failed to execute operation: %s", bus_error_message(&error, r));
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to execute operation: %s", bus_error_message(&error, r));
return 1;
}