summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaoran S. Diao <0@hairydiode.xyz>2019-03-02 11:42:22 -0500
committerHaoran S. Diao <0@hairydiode.xyz>2019-03-02 11:42:22 -0500
commite1f5a0e82f6db4bc59bac48f6cc0884febbce0f8 (patch)
tree1a5b659e3243955d16324ead338d52b5b2caa3c5
parentb6234542679b4c0bfa37c49c4fc32070298fd72e (diff)
script complete
-rwxr-xr-xmitclock38
1 files changed, 33 insertions, 5 deletions
diff --git a/mitclock b/mitclock
index 53185ae..a161d6a 100755
--- a/mitclock
+++ b/mitclock
@@ -1,7 +1,7 @@
#!/bin/bash
#function that prints a string $1 centered on line $2
-#if $3 is c, then it offsets from there
+#if $3 is c, then it offsets from there, $4 also modifies the line size
function ceprint ()
{
if [ "$3" == "c" ]; then
@@ -9,27 +9,55 @@ function ceprint ()
else
vpad=$2
fi
- pad=$(( $(( $(tput cols) - "${#1}" )) / 2 ))
+ pad=$(( $(( $(tput cols) - $(( "${#1}" + "$4" )) )) / 2 ))
echo -n "["
echo -n $vpad
echo -n ";"
echo -n $pad
echo -n "H"
#echo ""
- echo $1
+ echo -e "$1"
}
#main loop variable
+clear
LOOP=1
while [ $LOOP -eq 1 ]; do
+ ceprint "#### #### #### #### ###########" -5 c 0
+ ceprint "#### #### #### #### ###########" -4 c 0
+ ceprint "#### #### #### #### ###########" -3 c 0
+ ceprint "#### #### #### " -2 c 0
+ ceprint "#### #### #### #### ####" -1 c -2
+ ceprint "#### #### #### #### ####" 0 c -2
+ ceprint "#### #### #### #### ####" 1 c -2
+ ceprint "#### #### #### #### ####" 2 c -2
+ ceprint "#### #### #### ####" 3 c -2
+ ceprint "#### #### #### ####" 4 c -2
+ ceprint "#### #### #### ####" 5 c -2
+ ceprint "#### #### #### ####" 6 c -2
#Display Date in English
- ENGDATE=$(date -d@$(( 1552602480 - $(date +%s) )) \
+ ENDATE=$(date -d@$(( 1552602480 - $(date +%s) )) \
"+%-j Days %H Hours %M Minutes %S Seconds");
- ceprint "$ENGDATE" 1 c
+ ENDATE=$(echo $ENDATE | awk '$1=$1-1')
+ CNDATE=$(date -d@$(( 1552602480 - $(date +%s) )) \
+ "+%-j 天 %H 时 %M 分 %S 秒");
+ CNDATE=$(echo $CNDATE | awk '$1=$1-1')
+ ESDATE=$(date -d@$(( 1552602480 - $(date +%s) )) \
+ "+%-j Dias %H Horas %M Minutos %S Segundos");
+ ESDATE=$(echo $ESDATE | awk '$1=$1-1')
+ JPDATE=$(date -d@$(( 1552602480 - $(date +%s) )) \
+ "+%-j 日 %H 时 %M 分 %S 秒");
+ JPDATE=$(echo $JPDATE | awk '$1=$1-1')
+
+ ceprint "$ENDATE" 8 c 0
+ ceprint "$CNDATE" 9 c 4
+ ceprint "$ESDATE" 10 c 0
+ ceprint "$JPDATE" 11 c 4
#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