chiark / gitweb /
logind: unify all session lock loop
[elogind.git] / src / login / logind-button.c
index 753d95454c866f91108ebddbbf9c6412839617ea..8bbd731ae40569d727b480474734c0eb12c11aa0 100644 (file)
@@ -164,7 +164,7 @@ static int button_handle(
                 [HANDLE_KEXEC] = "Rebooting via kexec...",
                 [HANDLE_SUSPEND] = "Suspending...",
                 [HANDLE_HIBERNATE] = "Hibernating...",
-                [HANDLE_HYBRID_SLEEP] = "Hibernating and suspend...",
+                [HANDLE_HYBRID_SLEEP] = "Hibernating and suspending..."
         };
 
         static const char * const target_table[_HANDLE_BUTTON_MAX] = {
@@ -195,6 +195,13 @@ static int button_handle(
                 return 0;
         }
 
+        /* Locking is handled differently from the rest. */
+        if (handle == HANDLE_LOCK) {
+                log_info("Locking sessions...");
+                session_send_lock_all(b->manager, true);
+                return 1;
+        }
+
         inhibit_operation = handle == HANDLE_SUSPEND || handle == HANDLE_HIBERNATE || handle == HANDLE_HYBRID_SLEEP ? INHIBIT_SLEEP : INHIBIT_SHUTDOWN;
 
         /* If the actual operation is inhibited, warn and fail */
@@ -309,6 +316,7 @@ static const char* const handle_button_table[_HANDLE_BUTTON_MAX] = {
         [HANDLE_SUSPEND] = "suspend",
         [HANDLE_HIBERNATE] = "hibernate",
         [HANDLE_HYBRID_SLEEP] = "hybrid-sleep",
+        [HANDLE_LOCK] = "lock"
 };
 DEFINE_STRING_TABLE_LOOKUP(handle_button, HandleButton);
 DEFINE_CONFIG_PARSE_ENUM(config_parse_handle_button, handle_button, HandleButton, "Failed to parse handle button setting");