2006-06-02 19:53:17 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2006-06-10 18:48:25 +02:00
|
|
|
# Be sure that we know the taget name
|
2006-06-02 19:53:17 +02:00
|
|
|
[[ -z $1 ]] && exit
|
2006-06-10 18:48:25 +02:00
|
|
|
TARGET=$1 # Remember the target build we are looking for
|
2006-06-02 19:53:17 +02:00
|
|
|
|
2006-06-10 18:48:25 +02:00
|
|
|
declare -r CSI=$'\e[' # DEC terminology, Control Sequence Introducer
|
|
|
|
declare -r CURSOR_OFF=${CSI}$'?25l'
|
|
|
|
declare -r CURSOR_ON=${CSI}$'?25h'
|
|
|
|
declare -r ERASE_LINE=${CSI}$'2K'
|
|
|
|
declare -r FRAME_OPEN=${CSI}$'2G['
|
|
|
|
declare -r FRAME_CLOSE=${CSI}$'63G]'
|
|
|
|
declare -r TS_POSITION=${CSI}$'65G'
|
|
|
|
declare -a RESET_LINE=${CURSOR_OFF}${ERASE_LINE}${FRAME_OPEN}${FRAME_CLOSE}
|
|
|
|
|
|
|
|
declare -a GRAPHIC_STR="| / - \\ + "
|
|
|
|
declare -i SEC=0 # Seconds accumulator
|
|
|
|
declare -i PREV_SEC=0
|
|
|
|
|
|
|
|
|
|
|
|
write_or_exit() {
|
|
|
|
# make has been killed or failed or run to completion, leave
|
|
|
|
if ! fuser -v . 2>&1 | grep make >/dev/null ; then
|
|
|
|
echo -n "${CURSOR_ON}" && exit
|
|
|
|
fi
|
|
|
|
# Target build complete, leave.
|
|
|
|
[[ -f ${TARGET} ]] && echo -n "${CURSOR_ON}" && exit
|
|
|
|
# It is safe to write to the screen
|
|
|
|
echo -n "$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
# initialize screen
|
|
|
|
write_or_exit "${RESET_LINE}${TS_POSITION}0 min. 0 sec. "
|
|
|
|
|
|
|
|
# loop forever..
|
|
|
|
while true ; do
|
|
|
|
|
|
|
|
# Loop through the animation string
|
|
|
|
for GRAPHIC_CHAR in ${GRAPHIC_STR} ; do
|
|
|
|
write_or_exit "${CSI}$((SEC + 3))G${GRAPHIC_CHAR}"
|
|
|
|
sleep .12 # This value MUST be less than .2 seconds.
|
|
|
|
done
|
|
|
|
|
|
|
|
# A BASH internal variable, the number of seconds the script
|
|
|
|
# has been running. modulo convert to 0-59
|
|
|
|
SEC=$(($SECONDS % 60))
|
|
|
|
|
|
|
|
# Detect rollover of the seconds.
|
|
|
|
(( PREV_SEC > SEC )) && write_or_exit "${RESET_LINE}"
|
|
|
|
(( PREV_SEC = SEC ))
|
|
|
|
|
|
|
|
# Display the accumulated time. div minutes.. modulo seconds.
|
|
|
|
write_or_exit "${TS_POSITION}$(($SECONDS / 60)) min. $SEC sec. "
|
|
|
|
done
|
|
|
|
|
|
|
|
exit
|