]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: rework wall message about pending shutdown/halt/reboot/…
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 30 May 2022 10:08:41 +0000 (12:08 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 1 Jun 2022 07:23:05 +0000 (09:23 +0200)
Those messages simply *feel* dated: "The system is going for suspend NOW!".
Let's say "The system will suspend|power off|hibernate|… now!" instead.
The exclamation mark is enough to show the urgency.

Also, the "the" seemed out of place. We're not talking about a specific reboot.

src/login/logind-action.c
src/login/logind-action.h
src/login/logind-dbus.c
src/login/logind-utmp.c
src/login/logind.c
test/test-shutdown.py

index 76fdd2e9e6cdb61d64592bf29fd05f815a50c1a5..c6a36a1556cdfd68e00b9a5802891d1ad2ebc1a4 100644 (file)
@@ -251,6 +251,22 @@ int manager_handle_action(
         return 1;
 }
 
+static const char* const handle_action_verb_table[_HANDLE_ACTION_MAX] = {
+        [HANDLE_IGNORE]                 = "do nothing",
+        [HANDLE_POWEROFF]               = "power off",
+        [HANDLE_REBOOT]                 = "reboot",
+        [HANDLE_HALT]                   = "halt",
+        [HANDLE_KEXEC]                  = "kexec",
+        [HANDLE_SUSPEND]                = "suspend",
+        [HANDLE_HIBERNATE]              = "hibernate",
+        [HANDLE_HYBRID_SLEEP]           = "enter hybrid sleep",
+        [HANDLE_SUSPEND_THEN_HIBERNATE] = "suspend and later hibernate",
+        [HANDLE_FACTORY_RESET]          = "perform a factory reset",
+        [HANDLE_LOCK]                   = "be locked",
+};
+
+DEFINE_STRING_TABLE_LOOKUP_TO_STRING(handle_action_verb, HandleAction);
+
 static const char* const handle_action_table[_HANDLE_ACTION_MAX] = {
         [HANDLE_IGNORE]                 = "ignore",
         [HANDLE_POWEROFF]               = "poweroff",
index c891787e6cdcf8ac0f00dc4aace2c7cedf03b439..9a01af1690881a68b66614c292de212ef9bf629c 100644 (file)
@@ -49,6 +49,8 @@ int manager_handle_action(
                 bool ignore_inhibited,
                 bool is_edge);
 
+const char* handle_action_verb_to_string(HandleAction h) _const_;
+
 const char* handle_action_to_string(HandleAction h) _const_;
 HandleAction handle_action_from_string(const char *s) _pure_;
 
index f7cff580051493bd38898dd5b2c684bd7ad3a595..888d3f7906e088937969e61d7eafc37de93e3c4d 100644 (file)
@@ -2357,7 +2357,7 @@ static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userd
                 }
 
                 username = uid_to_name(uid);
-                utmp_wall("The system shutdown has been cancelled",
+                utmp_wall("System shutdown has been cancelled",
                           username, tty, logind_wall_tty_filter, m);
         }
 
index 1db5050c3b6eb25eabece99cace57ce5a62b2510..dfae1aa2ebd67c014fed0ceec46b261efe8e07b2 100644 (file)
@@ -70,11 +70,11 @@ static int warn_wall(Manager *m, usec_t n) {
 
         left = m->scheduled_shutdown_timeout > n;
 
-        r = asprintf(&l, "%s%sThe system is going down for %s %s%s!",
+        r = asprintf(&l, "%s%sThe system will %s %s%s!",
                      strempty(m->wall_message),
                      isempty(m->wall_message) ? "" : "\n",
-                     handle_action_to_string(m->scheduled_shutdown_action->handle),
-                     left ? "at " : "NOW",
+                     handle_action_verb_to_string(m->scheduled_shutdown_action->handle),
+                     left ? "at " : "now",
                      left ? FORMAT_TIMESTAMP(m->scheduled_shutdown_timeout) : "");
         if (r < 0) {
                 log_oom();
index 0483902edd9bec52af99452c1b3dd0ea9ceeca07..aa8548054841794a4a3d8d9d2146abd8fe9c4e76 100644 (file)
@@ -972,7 +972,7 @@ static int manager_dispatch_idle_action(sd_event_source *s, uint64_t t, void *us
 
                 if (n >= since.monotonic + m->idle_action_usec &&
                     (m->idle_action_not_before_usec <= 0 || n >= m->idle_action_not_before_usec + m->idle_action_usec)) {
-                        log_info("System idle. Doing %s operation.", handle_action_to_string(m->idle_action));
+                        log_info("System idle. Will %s now.", handle_action_verb_to_string(m->idle_action));
 
                         manager_handle_action(m, 0, m->idle_action, false, false);
                         m->idle_action_not_before_usec = n;
index 77ac3a7d9fb076fc16a778c3c58284eaec784639..060a0e651af6781328530850e70b7d0ac827526b 100755 (executable)
@@ -54,7 +54,7 @@ def run(args):
         console.send('0')
         logger.info("verify broadcast message")
         console.expect('Broadcast message from root@H on %s' % pty, 2)
-        console.expect('The system is going down for reboot at %s' % date, 2)
+        console.expect('The system will reboot at %s' % date, 2)
 
         logger.info("check show output")
         console.sendline('shutdown --show')
@@ -64,13 +64,13 @@ def run(args):
         console.sendline('shutdown -c')
         console.sendcontrol('a')
         console.send('1')
-        console.expect('The system shutdown has been cancelled', 2)
+        console.expect('System shutdown has been cancelled', 2)
 
         logger.info("call for reboot")
         console.sendline('sleep 10; shutdown -r now')
         console.sendcontrol('a')
         console.send('0')
-        console.expect("The system is going down for reboot NOW!", 12)
+        console.expect("The system will reboot now!", 12)
 
         logger.info("waiting for reboot")