diff options
author | William Harrington <kb0iic@berzerkula.org> | 2021-03-26 15:51:29 -0500 |
---|---|---|
committer | William Harrington <kb0iic@berzerkula.org> | 2021-03-26 15:56:48 -0500 |
commit | 72f924d31452c381ff4dc4edd44bc4fef448b43b (patch) | |
tree | 0e708cf4e4590474b44f65d9dd35b20b9c5db2ed /functions.sh | |
parent | 4e90c611e6c52be116badd6bf477495dcb370fe8 (diff) |
Remove spinner script and move spinner function to functions.
Diffstat (limited to 'functions.sh')
-rw-r--r-- | functions.sh | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/functions.sh b/functions.sh index d2ff5be..6b8671a 100644 --- a/functions.sh +++ b/functions.sh @@ -12,8 +12,54 @@ download() printf "%b" "${RED}FAILED! WGET EXIT (${retval})\n${RST}" exit "${retval}" fi - printf "%b" "\b\b\b\b\n" tput cnorm } export -f download + +## spinner takes the pid of the process as the first argument and +# string to display as second argument (default provided) and spins +# until the process completes. +spinner() { + local proc="$1" + #local str="${2:-'Copyright of KatworX© Tech. Developed by Arjun Singh Kathait and Debugged by the ☆Stack Overflow Community☆'}" + local str="" + local delay="0.1" + tput civis # hide cursor + printf "%b" "${WHT}" + while [ -d /proc/"$proc" ]; do + #-\|/ + #⠁⠂⠄⡀⢀⠠⠐⠈ + #▁▂▃▄▅▆▇█▇▆▅▄▃▂▁ + #←↖↑↗→↘↓↙ + #▖▘▝▗ + #◢◣◤◥ + #┤┘┴└├┌┬┐ + #◰◳◲◱ + #◴◷◶◵ + #◐◓◑◒ + #⣾⣽⣻⢿⡿⣟⣯⣷ + printf '\033[s\033[u[ ▁ ] %s\033[u' "$str"; sleep "$delay" + printf '\033[s\033[u[ ▂ ] %s\033[u' "$str"; sleep "$delay" + printf '\033[s\033[u[ ▃ ] %s\033[u' "$str"; sleep "$delay" + printf '\033[s\033[u[ ▄ ] %s\033[u' "$str"; sleep "$delay" + printf '\033[s\033[u[ ▅ ] %s\033[u' "$str"; sleep "$delay" + printf '\033[s\033[u[ ▆ ] %s\033[u' "$str"; sleep "$delay" + printf '\033[s\033[u[ ▇ ] %s\033[u' "$str"; sleep "$delay" + printf '\033[s\033[u[ █ ] %s\033[u' "$str"; sleep "$delay" + printf '\033[s\033[u[ ▇ ] %s\033[u' "$str"; sleep "$delay" + printf '\033[s\033[u[ ▆ ] %s\033[u' "$str"; sleep "$delay" + printf '\033[s\033[u[ ▅ ] %s\033[u' "$str"; sleep "$delay" + printf '\033[s\033[u[ ▄ ] %s\033[u' "$str"; sleep "$delay" + printf '\033[s\033[u[ ▃ ] %s\033[u' "$str"; sleep "$delay" + printf '\033[s\033[u[ ▂ ] %s\033[u' "$str"; sleep "$delay" + printf '\033[s\033[u[ ▁ ] %s\033[u' "$str"; sleep "$delay" + done + wait "${proc}" + retval=$? + printf '\033[s\033[u%*s\033[u\033[0m' $((${#str}+6)) " " # return to normal + tput cnorm # restore cursor + return $retval +} + +export -f spinner |