diff options
-rw-r--r-- | chapter6/backup.sh | 2 | ||||
-rw-r--r-- | env.sh | 5 | ||||
-rw-r--r-- | functions.sh | 44 | ||||
-rw-r--r-- | packageinstall.sh | 6 |
4 files changed, 37 insertions, 20 deletions
diff --git a/chapter6/backup.sh b/chapter6/backup.sh index 6d23c27..f710037 100644 --- a/chapter6/backup.sh +++ b/chapter6/backup.sh @@ -10,7 +10,7 @@ else echo -ne "${GRN}Backing up ${YLW}${LFS}${GRN} to ${YLW}${file}${RST}... " pushd "${LFS}" > /dev/null || exit 1 sudo XZ_OPTS="-T${NUMPROCS} -e" tar cJpf "${HOME}"/"${file}" "${directories[@]}" >/dev/null 2>&1 & pid=$! - spinner "$pid" + spinner "$pid" "${SPINNER}" retval=$? if [ "$retval" -ne 0 ]; then printf "%b" "${RED}FAILED!${RST}\n" @@ -37,3 +37,8 @@ unset numjobs export PS1 LC_ALL LFS LFS_TGT PATH CONFIG_SITE export LFS_VER LFS_DISK LFS_PART LFS_PWD NUMPROCS MAKEFLAGS + + +# Set spinner type (0-11 in funtions.sh) +SPINNER=0 +export SPINNER diff --git a/functions.sh b/functions.sh index 8c5bd93..9a2e685 100644 --- a/functions.sh +++ b/functions.sh @@ -33,56 +33,68 @@ function cursorBack() { function spinner() { # make sure we use non-unicode character type locale # (that way it works for any locale as long as the font supports the characters) + local numspinners=12 + local LC_CTYPE=C local pid=$1 # Process Id of the previous running command - case $(($RANDOM % 12)) in + local spintype=$2 + + if [ -z "${spintype}" ] || [ "${spintype}" -ge "${numspinners}" ]; then + spintype=$((RANDOM % numspinners)) + fi + + case "${spintype}" in 0) - local spin='⠁⠂⠄⡀⢀⠠⠐⠈' - local charwidth=3 + local spin='.oO0Oo' + local charwidth=1 ;; 1) local spin='-\|/' local charwidth=1 ;; 2) - local spin="▁▂▃▄▅▆▇█▇▆▅▄▃▂▁" + local spin='⠁⠂⠄⡀⢀⠠⠐⠈' local charwidth=3 ;; 3) - local spin="▉▊▋▌▍▎▏▎▍▌▋▊▉" + local spin="▁▂▃▄▅▆▇█▇▆▅▄▃▂▁" local charwidth=3 ;; 4) - local spin='←↖↑↗→↘↓↙' + local spin="▉▊▋▌▍▎▏▎▍▌▋▊▉" local charwidth=3 ;; 5) - local spin='▖▘▝▗' + local spin='←↖↑↗→↘↓↙' local charwidth=3 ;; 6) - local spin='┤┘┴└├┌┬┐' + local spin='▖▘▝▗' local charwidth=3 ;; 7) - local spin='◢◣◤◥' + local spin='┤┘┴└├┌┬┐' local charwidth=3 ;; 8) - local spin='◰◳◲◱' + local spin='◢◣◤◥' local charwidth=3 ;; 9) - local spin='◴◷◶◵' + local spin='◰◳◲◱' local charwidth=3 ;; 10) - local spin='◐◓◑◒' + local spin='◴◷◶◵' local charwidth=3 ;; 11) + local spin='◐◓◑◒' + local charwidth=3 + ;; + 12) local spin='⣾⣽⣻⢿⡿⣟⣯⣷' local charwidth=3 ;; @@ -91,14 +103,14 @@ function spinner() { local i=0 tput civis # cursor invisible tput bold setaf 7 - while kill -0 $pid 2>/dev/null; do - local i=$(((i + $charwidth) % ${#spin})) + while kill -0 "$pid" 2>/dev/null; do + local i=$(((i + charwidth) % ${#spin})) printf "%b" "${spin:$i:$charwidth}" cursorBack 1 - sleep .1 + sleep .2 done tput cnorm - wait $pid # capture exit code + wait "$pid" # capture exit code return $? } diff --git a/packageinstall.sh b/packageinstall.sh index 5105fbb..afd11a0 100644 --- a/packageinstall.sh +++ b/packageinstall.sh @@ -16,9 +16,9 @@ else # Remove existing if exists rm -rf "${DIRNAME}" - printf "%b" "${IBLU}Extracting ${YLW}${CACHEFILE}... " + printf "%b" "${IBLU}Extracting ${YLW}${CACHEFILE}... ${RST}" tar xf "${CACHEFILE}" > /dev/null 2>&1 & pid=$! - spinner "$pid" + spinner "$pid" "${SPINNER}" retval=$? if [ "$retval" -ne 0 ]; then printf "%b" "${GRN}Extraction ${RED}FAILED!${RST}\n" @@ -33,7 +33,7 @@ else mkdir -p "${LFS}/sources/log/chapter${CHAPTER}/" source "${LFS}/sources/chapter${CHAPTER}/${PACKAGE}.sh" 2>&1 > "${LFS}/sources/log/chapter${CHAPTER}/${PACKAGE}.log" 2>&1 & pid=$! - spinner "$pid" + spinner "$pid" "${SPINNER}" retval=$? if [ "$retval" -ne 0 ]; then printf "%b" "${RED}FAILED!${RST}\n" |