#!/bin/bash #function that prints a string $1 centered on line $2 #if $3 is c, then it offsets from there, $4 also modifies the line size function ceprint () { if [ "$3" == "c" ]; then vpad=$(( $(( $(tput lines) /2 )) + $2 )) else vpad=$2 fi pad=$(( $(( $(tput cols) - $(( "${#1}" + "$4" )) )) / 2 )) echo -n "[" echo -n $vpad echo -n ";" echo -n $pad echo -n "H" #echo "" 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 SECONDS=$(( 1552602480 - $(date +%s) )) if [ $SECONDS -le 0 ]; then LOOP=0 #plays song mocp -l song* ceprint "成败尚未卜定" $(( $(tput lines) - 1 )) "n" 6 break fi #Abuses date to display the difference between now and March 14 6:28 ENDATE=$(TZ="GMT" date -d@$SECONDS \ "+%-j Days %H Hours %M Minutes %S Seconds"); ENDATE=$(echo $ENDATE | awk '{$1=$1-1;print $0}') CNDATE=$(TZ="GMT" date -d@$SECONDS \ "+%-j 天 %H 时 %M 分 %S 秒"); CNDATE=$(echo $CNDATE | awk '{$1=$1-1;print $0}') ESDATE=$(TZ="GMT" date -d@$SECONDS \ "+%-j Dias %H Horas %M Minutos %S Segundos"); ESDATE=$(echo $ESDATE | awk '{$1=$1-1;print $0}') JPDATE=$(TZ="GMT" date -d@$SECONDS \ "+%-j 日 %H 时 %M 分 %S 秒"); JPDATE=$(echo $JPDATE | awk '{$1=$1-1;print $0}') 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