#!/bin/bash if [[ $# -lt 2 ]]; then echo "Usage: deadline " return -1 fi deadline_name=${1:-"THE DEADLINE"} target_date=${2:-"2048-01-01 00:08:00"} stress_below=${3:-14} target_epoch=$(date -d "$target_date" +%s) now_epoch=$(date +%s) remaining_seconds=$((target_epoch - now_epoch)) if [[ $remaining_seconds -lt 0 ]]; then echo "\033[33mDeadline has passed. Rest in peace.\033[0m" else days=$((remaining_seconds / 86400)) hours=$(((remaining_seconds % 86400) / 3600)) minutes=$(((remaining_seconds % 3600) / 60)) seconds=$((remaining_seconds % 60)) color="33" if [[ $days -le $stress_below ]]; then color="31" #flash=$((100 - ((days * 100 + 1) / $stress_below))) fi if [[ days -le $stress_below ]]; then printf "\e[${color}m ! DEADLINE SET FOR <%s> (%s)\e[0m\n" "$deadline_name" "$target_date" $QASH_LIBRARY_DIR/stressuser.sh "\e[${color}m ! --- $days:$hours:$minutes:$seconds REMAINING --- \n" $color .48 else printf "\e[${color}m\e[5m ! DEADLINE SET FOR <%s> (%s)\e[0m\n" "$deadline_name" "$target_date" printf "\e[0m ! --- roughly $days days remaining, no biggie --- \e[0m\n" fi fi