Created
March 23, 2021 13:39
-
-
Save Beaglefoot/d4b98bb4437070d58617edf640099e06 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
function h2s() { | |
local hours=$1 | |
echo "${wait_time:0:-1} * 3600" | bc | cut -d. -f1 | |
} | |
function humanize_duration() { | |
local total_seconds=$1 | |
local hours=$(( $total_seconds / 3600 )) | |
local minutes=$(( ($total_seconds - $hours * 3600) / 60 )) | |
local seconds=$(( $total_seconds % 60 )) | |
printf "%02d:%02d:%02d" ${hours} ${minutes} ${seconds} | |
} | |
function clear_line() { | |
echo -ne "\033[K" | |
} | |
wait_time="1.25h" | |
notification_timeout_ms=600000 | |
wait_seconds=$(h2s $wait_time) | |
breaks_count=1 | |
echo | |
while true; do | |
clear_line | |
echo -ne "\r($breaks_count) Next break in: $(humanize_duration $wait_seconds)" | |
if [[ $wait_seconds == 0 ]]; then | |
notify-send -t ${notification_timeout_ms} "Break may be?" | |
echo | |
(( breaks_count++ )) | |
wait_seconds=$(h2s $wait_time) | |
continue | |
fi | |
sleep 1 | |
(( wait_seconds-- )) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment