mirror of
https://github.com/levogevo/ffmpeg-builder.git
synced 2026-01-15 19:06:17 +00:00
improvements to spinner
This commit is contained in:
32
lib/utils.sh
32
lib/utils.sh
@@ -324,18 +324,16 @@ bash_sort() {
|
||||
printf '%s\n' "${arr[@]}"
|
||||
}
|
||||
|
||||
spinner() {
|
||||
if [[ $1 == 'reset' ]]; then
|
||||
echo -ne ' \n'
|
||||
return 0
|
||||
fi
|
||||
|
||||
_start_spinner() {
|
||||
local spinChars=(
|
||||
"-"
|
||||
'\'
|
||||
"|"
|
||||
"/"
|
||||
)
|
||||
|
||||
sleep 1
|
||||
|
||||
while true; do
|
||||
for ((ind = 0; ind < "${#spinChars[@]}"; ind++)); do
|
||||
echo -ne "${spinChars[${ind}]}" '\b\b'
|
||||
@@ -344,6 +342,28 @@ spinner() {
|
||||
done
|
||||
}
|
||||
|
||||
spinner() {
|
||||
local action="$1"
|
||||
local spinPidFile="${TMP_DIR}/.spinner-pid"
|
||||
case "${action}" in
|
||||
start)
|
||||
test -f "${spinPidFile}" &&
|
||||
rm "${spinPidFile}"
|
||||
|
||||
# don't want to clutter logs if running headless
|
||||
test "${HEADLESS}" == '1' &&
|
||||
return
|
||||
|
||||
_start_spinner &
|
||||
echo $! >"${spinPidFile}"
|
||||
;;
|
||||
stop)
|
||||
test -f "${spinPidFile}" && kill "$(<"${spinPidFile}")"
|
||||
echo -ne ' \n'
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
get_pkgconfig_version() {
|
||||
local pkg="$1"
|
||||
pkg-config --modversion "${pkg}"
|
||||
|
||||
Reference in New Issue
Block a user