diff options
-rwxr-xr-x | mitclock | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/mitclock b/mitclock new file mode 100755 index 0000000..53185ae --- /dev/null +++ b/mitclock @@ -0,0 +1,35 @@ +#!/bin/bash + +#function that prints a string $1 centered on line $2 +#if $3 is c, then it offsets from there +function ceprint () +{ + if [ "$3" == "c" ]; then + vpad=$(( $(( $(tput lines) /2 )) + $2 )) + else + vpad=$2 + fi + pad=$(( $(( $(tput cols) - "${#1}" )) / 2 )) + echo -n "[" + echo -n $vpad + echo -n ";" + echo -n $pad + echo -n "H" + #echo "[1;2H" + echo $1 +} + +#main loop variable +LOOP=1 +while [ $LOOP -eq 1 ]; do + #Display Date in English + ENGDATE=$(date -d@$(( 1552602480 - $(date +%s) )) \ + "+%-j Days %H Hours %M Minutes %S Seconds"); + ceprint "$ENGDATE" 1 c + #Reads for 0.5 Seconds, provides rough timing of the loop and allows for + #exit + read -t 0.5 -N 1 READCHAR + if [ "$READCHAR" == "q" ]; then + LOOP=0 + fi +done |