From 0e7f66e7cbf4c64805d15211767f6547498d4019 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 30 May 2022 12:08:41 +0200 Subject: [PATCH] =?utf8?q?logind:=20rework=20wall=20message=20about=20pend?= =?utf8?q?ing=20shutdown/halt/reboot/=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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. (cherry picked from commit 3dbb9bc5eb29b7f3cfcbe61c05922c5360be19ec) Gbp-Pq: Name logind-rework-wall-message-about-pending-shutdown-halt-re.patch --- src/login/logind-action.c | 16 ++++++++++++++++ src/login/logind-action.h | 2 ++ src/login/logind-dbus.c | 2 +- src/login/logind-utmp.c | 6 +++--- src/login/logind.c | 2 +- test/test-shutdown.py | 6 +++--- 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/login/logind-action.c b/src/login/logind-action.c index 6a873009..55b34e5e 100644 --- a/src/login/logind-action.c +++ b/src/login/logind-action.c @@ -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", diff --git a/src/login/logind-action.h b/src/login/logind-action.h index c891787e..9a01af16 100644 --- a/src/login/logind-action.h +++ b/src/login/logind-action.h @@ -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_; diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 6b77a04d..8fd46e1a 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -2355,7 +2355,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); } diff --git a/src/login/logind-utmp.c b/src/login/logind-utmp.c index 7d761a0d..848d96c2 100644 --- a/src/login/logind-utmp.c +++ b/src/login/logind-utmp.c @@ -78,11 +78,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(); diff --git a/src/login/logind.c b/src/login/logind.c index 0483902e..aa854805 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -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; diff --git a/test/test-shutdown.py b/test/test-shutdown.py index 1a91753b..a9c43e30 100755 --- a/test/test-shutdown.py +++ b/test/test-shutdown.py @@ -53,7 +53,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') @@ -63,13 +63,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") -- 2.30.2