From ecc196e5f824bb4412a29d3fd47c285309d00d58 Mon Sep 17 00:00:00 2001 From: Robin Candau Date: Sun, 19 May 2024 23:04:29 +0200 Subject: [PATCH] Make the reboot countdown after a kernel upgrade showing remaining seconds in real time (#169) * Make the reboot countdown after a kernel upgrade showing remaining seconds in real time This commit makes the 5 seconds countdow before a reboot to apply a pending kernel update show the remaining seconds in real time. --- po/arch-update.pot | 14 +++++++------- po/fr.po | 16 ++++++++-------- src/script/arch-update.sh | 14 ++++++++++++-- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/po/arch-update.pot b/po/arch-update.pot index 6bca749..70362d4 100644 --- a/po/arch-update.pot +++ b/po/arch-update.pot @@ -423,38 +423,38 @@ msgstr "" msgid "Would you like to reboot now? [y/N]" msgstr "" -#: src/script/arch-update.sh:609 +#: src/script/arch-update.sh:616 #, sh-format -msgid "Rebooting in 5 seconds...\\nPress ctrl+c to abort" +msgid "Rebooting in ${sec}...\\r" msgstr "" -#: src/script/arch-update.sh:613 +#: src/script/arch-update.sh:622 #, sh-format msgid "" "An error has occurred during the reboot process\\nThe reboot has been " "aborted\\n" msgstr "" -#: src/script/arch-update.sh:621 +#: src/script/arch-update.sh:630 #, sh-format msgid "" "The reboot hasn't been performed\\nPlease, consider rebooting to finalize " "the pending kernel update\\n" msgstr "" -#: src/script/arch-update.sh:625 +#: src/script/arch-update.sh:634 #, sh-format msgid "No pending kernel update found\\n" msgstr "" -#: src/script/arch-update.sh:673 +#: src/script/arch-update.sh:682 #, sh-format msgid "" "The '${config_file}' configuration file already exists\\nPlease, remove it " "before generating a new one" msgstr "" -#: src/script/arch-update.sh:678 +#: src/script/arch-update.sh:687 #, sh-format msgid "The '${config_file}' configuration file has been generated" msgstr "" diff --git a/po/fr.po b/po/fr.po index 1944a53..a4a4cf6 100644 --- a/po/fr.po +++ b/po/fr.po @@ -452,12 +452,12 @@ msgstr "" msgid "Would you like to reboot now? [y/N]" msgstr "Voulez-vous redémarrer votre système maintenant ? [o/N]" -#: src/script/arch-update.sh:609 +#: src/script/arch-update.sh:616 #, sh-format -msgid "Rebooting in 5 seconds...\\nPress ctrl+c to abort" -msgstr "Redémarrage dans 5 secondes...\\nAppuyez sur ctrl+c pour annuler" +msgid "Rebooting in ${sec}...\\r" +msgstr "Redémarrage dans ${sec}...\\r" -#: src/script/arch-update.sh:613 +#: src/script/arch-update.sh:622 #, sh-format msgid "" "An error has occurred during the reboot process\\nThe reboot has been " @@ -466,7 +466,7 @@ msgstr "" "Une erreur est survenue pendant le processus de redémarrage\\nLe redémarrage a été " "abandonné\\n" -#: src/script/arch-update.sh:621 +#: src/script/arch-update.sh:630 #, sh-format msgid "" "The reboot hasn't been performed\\nPlease, consider rebooting to finalize " @@ -475,12 +475,12 @@ msgstr "" "Le redémarrage n'a pas été effectué\\nVeuillez considérer redémarrer votre système pour finaliser " "la mise à jour du noyau en attente\\n" -#: src/script/arch-update.sh:625 +#: src/script/arch-update.sh:634 #, sh-format msgid "No pending kernel update found\\n" msgstr "Aucune mise à jour du noyau en attente n'a été trouvée\\n" -#: src/script/arch-update.sh:673 +#: src/script/arch-update.sh:682 #, sh-format msgid "" "The '${config_file}' configuration file already exists\\nPlease, remove it " @@ -489,7 +489,7 @@ msgstr "" "Le fichier de configuration '${config_file}' existe déjà.\\nVeuillez le supprimer " "avant d'en générer un nouveau" -#: src/script/arch-update.sh:678 +#: src/script/arch-update.sh:687 #, sh-format msgid "The '${config_file}' configuration file has been generated" msgstr "Le fichier de configuration '${config_file}' a été généré" diff --git a/src/script/arch-update.sh b/src/script/arch-update.sh index 43a67a6..c86fd32 100755 --- a/src/script/arch-update.sh +++ b/src/script/arch-update.sh @@ -606,8 +606,18 @@ kernel_reboot() { case "${answer}" in "$(eval_gettext "Y")"|"$(eval_gettext "y")") echo - main_msg "$(eval_gettext "Rebooting in 5 seconds...\nPress ctrl+c to abort")" - sleep 5 + + # shellcheck disable=SC2317,SC2329 + restore_cursor() { + tput cnorm + } + trap restore_cursor EXIT + # shellcheck disable=SC2034 + for sec in {5..1}; do + tput civis ; echo -ne "${blue}==>${color_off}${bold} $(eval_gettext "Rebooting in \${sec}...\r")${color_off}" + sleep 1 + done + if ! reboot; then echo error_msg "$(eval_gettext "An error has occurred during the reboot process\nThe reboot has been aborted\n")" && quit_msg