[a858a78] | 1 | #!/bin/bash
|
---|
| 2 |
|
---|
| 3 | # $Id$
|
---|
| 4 |
|
---|
| 5 | set -e
|
---|
| 6 |
|
---|
[843c479] | 7 | # Be sure that we know the taget name
|
---|
[a36805d] | 8 | [[ -z $1 ]] && exit
|
---|
[843c479] | 9 | TARGET=$1 # Remember the target build we are looking for
|
---|
[a36805d] | 10 |
|
---|
[843c479] | 11 | declare -r CSI=$'\e[' # DEC terminology, Control Sequence Introducer
|
---|
| 12 | declare -r CURSOR_OFF=${CSI}$'?25l'
|
---|
| 13 | declare -r CURSOR_ON=${CSI}$'?25h'
|
---|
| 14 | declare -r ERASE_LINE=${CSI}$'2K'
|
---|
| 15 | declare -r FRAME_OPEN=${CSI}$'2G['
|
---|
| 16 | declare -r FRAME_CLOSE=${CSI}$'63G]'
|
---|
| 17 | declare -r TS_POSITION=${CSI}$'65G'
|
---|
| 18 | declare -a RESET_LINE=${CURSOR_OFF}${ERASE_LINE}${FRAME_OPEN}${FRAME_CLOSE}
|
---|
| 19 |
|
---|
| 20 | declare -a GRAPHIC_STR="| / - \\ + "
|
---|
| 21 | declare -i MIN=0 # Start value for minutes
|
---|
| 22 | declare -i SEC=0 # Seconds accumulator
|
---|
| 23 | declare -i POS=0 # Start value for seconds/cursor position
|
---|
| 24 |
|
---|
| 25 | write_or_exit() {
|
---|
[7dd28ea] | 26 | # make has been killed or failed or run to completion, leave
|
---|
[843c479] | 27 | if ! fuser -v . 2>&1 | grep make >/dev/null ; then
|
---|
| 28 | echo -n "${CURSOR_ON}" && exit
|
---|
| 29 | fi
|
---|
| 30 | # Target build complete, leave. If we are here, make is alive and a new
|
---|
| 31 | # package target may has been started. Close this instance of the script.
|
---|
| 32 | # The cursor will be restored by echo-finished in makefile-functions.
|
---|
| 33 | [[ -f ${TARGET} ]] && exit
|
---|
| 34 | # It is safe to write to the screen
|
---|
| 35 | echo -n "$1"
|
---|
| 36 | }
|
---|
| 37 |
|
---|
[7dd28ea] | 38 | # This will loop forever.. or overflow, which ever comes first :)
|
---|
[843c479] | 39 | for ((MIN=0; MIN >= 0; MIN++)); do
|
---|
| 40 | write_or_exit "${RESET_LINE}${TS_POSITION}${MIN} min. 0 sec. "
|
---|
| 41 | # Count the seconds
|
---|
| 42 | for ((SEC=1, POS=3; SEC <= 60; SEC++, POS++)); do
|
---|
| 43 | for GRAPHIC_CHAR in ${GRAPHIC_STR} ; do
|
---|
| 44 | write_or_exit "${CSI}${POS}G${GRAPHIC_CHAR}"
|
---|
| 45 | sleep .2
|
---|
| 46 | done
|
---|
[7dd28ea] | 47 | # Display the accumlated time.
|
---|
[843c479] | 48 | write_or_exit "${TS_POSITION}${MIN} min. ${SEC} sec. "
|
---|
[a36805d] | 49 | done
|
---|
[843c479] | 50 | done
|
---|
| 51 | exit
|
---|
| 52 |
|
---|