summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaoran S. Diao <0@hairydiode.xyz>2019-02-28 14:03:01 -0500
committerHaoran S. Diao <0@hairydiode.xyz>2019-02-28 14:03:01 -0500
commitb6234542679b4c0bfa37c49c4fc32070298fd72e (patch)
treeae2d0313e717801be75438b4c78e66dad3e6175e
basic functionality
-rwxr-xr-xmitclock35
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 ""
+ 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