From 86dd4dd7849e3d7af7a38fd44e1058814076bc65 Mon Sep 17 00:00:00 2001 From: nate Date: Mon, 28 Mar 2016 18:45:55 -0500 Subject: [PATCH] New spinner for gravity.sh Spinner in gravity.sh now matches basic-install.sh and uninstall.sh --- gravity.sh | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/gravity.sh b/gravity.sh index 3434ac9c..ed94448b 100755 --- a/gravity.sh +++ b/gravity.sh @@ -75,18 +75,19 @@ if [[ -r $piholeDir/pihole.conf ]];then fi -spinner(){ - local pid=$1 - - spin='-\|/' - i=0 - while $SUDO kill -0 "$pid" 2>/dev/null - do - i=$(( (i+1) %4 )) - printf "\b%s" "${spin:$i:1}" - sleep .1 - done - printf "\b" +spinner() +{ + local pid=$1 + local delay=0.50 + local spinstr='|/-\' + while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do + local temp=${spinstr#?} + printf " [%c] " "$spinstr" + local spinstr=$temp${spinstr%"$temp"} + sleep $delay + printf "\b\b\b\b\b\b" + done + printf " \b\b\b\b" } ###########################