From f948900e437201789c8ed17300dd2eaa749d31a7 Mon Sep 17 00:00:00 2001 From: haskal Date: Thu, 3 Dec 2020 01:09:19 -0500 Subject: [PATCH] add fancy countdown timer (in bash) --- scripts/countdown | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 scripts/countdown diff --git a/scripts/countdown b/scripts/countdown new file mode 100755 index 0000000..513e3bc --- /dev/null +++ b/scripts/countdown @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# 👆 hazel i hope you're happy + +# challenges released in EST +export TZ="America/New_York" + +function init_day { + day=$(($(date +%d))) + + if [ ! -f $day.rkt ]; then + scripts/make-day $day + scripts/get-challenge $day + return 1 + fi + return 0 +} + +if init_day; then + next_day=$(($day + 1)) + next_timestamp=$(date --date="$(date +%Y-%m)-$next_day" +%s) + while true; do + secs_left=$(($next_timestamp - $(date +%s))) + if [ $secs_left -le 0 ]; then + break + fi + printf "\r\x1b[K%s secs left..." "$secs_left" + done + printf "\r\x1b[K" + init_day +fi