From 9f734933d67000c7a670d824574bbd181388dbd6 Mon Sep 17 00:00:00 2001 From: Tobias Powalowski Date: Wed, 30 Aug 2023 21:35:02 +0200 Subject: [PATCH] dynamic progressbar --- usr/bin/archboot-localize.sh | 18 ++++++++++++------ usr/lib/archboot/basic-common.sh | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/usr/bin/archboot-localize.sh b/usr/bin/archboot-localize.sh index 69ec48497..4f75571d0 100755 --- a/usr/bin/archboot-localize.sh +++ b/usr/bin/archboot-localize.sh @@ -59,9 +59,10 @@ _vconsole() { echo KEYMAP="${_KEYMAP}" > /etc/vconsole.conf echo FONT="${_FONT}" >> /etc/vconsole.conf systemctl restart systemd-vconsole-setup + rm /.archboot } -_run() { +_locale() { echo "LANG=${_LOCALE}.UTF-8" > /etc/locale.conf echo "LANG=${_LOCALE}.UTF-8" > /.localize echo LC_COLLATE=C >> /etc/locale.conf @@ -69,11 +70,16 @@ _run() { sed -i -e "s:^[a-z]:#&:g" /etc/locale.gen sed -i -e "s:^#${_LOCALE}.UTF-8:${_LOCALE}.UTF-8:g" /etc/locale.gen locale-gen &>"${_NO_LOG}" - _progress "33" "Setting locale to ${_LOCALE}.UTF-8..." - sleep 2 - _progress "66" "Setting keymap to ${_KEYMAP}..." - _vconsole - sleep 2 + rm /.archboot +} + +_run() { + : >/.archboot + _locale & + _progress_wait "0" "66" "Setting locale to ${_LOCALE}.UTF-8..." "0.1" + : >/.archboot + _vconsole & + _progress_wait "67" "99" "Setting keymap to ${_KEYMAP}..." "0.1" _progress "100" "Localization completed successfully." sleep 2 } diff --git a/usr/lib/archboot/basic-common.sh b/usr/lib/archboot/basic-common.sh index 767a1fd2f..d0a60f2f7 100644 --- a/usr/lib/archboot/basic-common.sh +++ b/usr/lib/archboot/basic-common.sh @@ -30,6 +30,22 @@ XXX EOF } +# $1: start percentage $2: end percentage $3: message $4: sleep time +_progress_wait() { + _COUNT=${1} + while true; do + if [[ "${_COUNT}" -lt "${2}" ]]; then + _progress "${_COUNT}" "${3}" + fi + if [[ "${_COUNT}" -gt "${2}" ]]; then + _progress "${2}" "${3}" + fi + _COUNT="$((_COUNT+1))" + read -r -t "${4}" + ! [[ -e /.archboot ]] && break + done +} + _show_login() { [[ -e "/.${_ANSWER}-running" ]] && rm "/.${_ANSWER}-running" clear