Scripts bash que utilizo en Android con herramientas de utilidad para mí día a día.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Termux-shell/gnz_cuentaAtras.sh

97 lines
2.2 KiB

source fnc_gonzy.sh
function fnc_principal(){
fnc_gonzy_intro "Cuenta Atras" "Cuenta regresiva."
read -p "Segundos?: " VarCountSec;
#read -p "Pantalla completa?: " VarCountTip;
read -p "Pantalla completa (S/N)?: " -n 1 -r VarCountTip
#if [$VarCountTip ==""]; then
if [[ ! $VarCountTip =~ ^[Ss]$ ]] then
countdown_a $VarCountSec
else
countdown_b $VarCountSec
fi
}
function countdown_a(){
seconds=$1
vsec=$seconds
vlim=3
vlim_a=$(((seconds/vlim)*2))
vlim_b=$((seconds/vlim))
start="$(($(date +%s) + $seconds))"
clear
while [ "$start" -ge `date +%s` ]; do
clear
time="$(( $start - `date +%s` ))"
if [ $vsec -le $vlim_a ]; then
echo -e "${Yellow}";
printf '%s\r' "$(date -u -d "@$time" +%H:%M:%S)" | figlet;
echo -e "${Color_Off}";
if [ $vsec -le $vlim_b ]; then
clear
echo -e "${Red}";
printf '%s\r' "$(date -u -d "@$time" +%H:%M:%S)" | figlet;
echo -e "${Color_Off}";
fi
else
echo -e "${Green}";
printf '%s\r' "$(date -u -d "@$time" +%H:%M:%S)" | figlet;
echo -e "${Color_Off}";
fi
sleep 1
vsec=$((vsec - 1))
done
fnc_msg_color 2 "Tiempo terminado!"
echo -e "\n"
}
function countdown_b(){
Set Variables
cols=$( tput cols )
rows=$( tput lines )
middle_row=$(( $rows / 2 ))
middle_col=$(( ($cols /2) - 4 ))
hour=0
min=0
sec=$1
donso () {
tput sgr0
tput cup $( tput lines ) 0
tput cnorm
}
tput clear
tput bold
tput civis
while [ $hour -ge 0 ]; do
while [ $min -ge 0 ]; do
while [ $sec -ge 0 ]; do
if [ "$hour" -eq "0" ] && [ "$min" -eq "0" ]; then
tput setab 3
tput clear
fi
if [ "$hour" -eq "0" ] && [ "$min" -eq "0" ] && [ "$sec" -le "10" ]; then
tput setab 1
tput clear
fi
tput cup $middle_row $middle_col
echo -ne "$(printf %02d:%02d:%02d $hour $min $sec)\e"
let "sec=sec-1"
sleep 1
done
sec=59
let "min=min-1"
done
min=59
let "hour=hour-1"
done
echo -e "${RESET}"
donso
}
fnc_principal