diff --git a/sunset-alarm b/sunset-alarm index 0de1218..749d216 100755 --- a/sunset-alarm +++ b/sunset-alarm @@ -94,8 +94,12 @@ fetch_sunset_time() { # Show alert via fallback chain: fyi -> notify-send -> wall ############################################################################### show_alert() { - TITLE="Sunset Alarm" - MESSAGE="Sunset is at $(date -d @${SUNSET_EPOCH} +"%H:%M")." + ALERT=$(date -d @${ALERT_WINDOW_START} +"%H:%M") + SUNSET=$(date -d @${SUNSET_EPOCH} +"%H:%M") + PLURAL=$(if (( $MINUTES != 1 )); then echo "s"; fi) + + TITLE="Sunset Alarm ($ALERT)" + MESSAGE="It's ${MINUTES} minute${PLURAL} to $SUNSET." persistent="-t 0 --wait" icon="-i weather-clear -u critical" @@ -159,13 +163,12 @@ while true; do if [ "$CURRENT_TIME" -ge "$ALERT_WINDOW_START" ] && \ [ "$CURRENT_TIME" -lt "$MIDNIGHT" ]; then show_alert - sleep 5 # Re-alert every 5 minutes while in alert window - else - sleep 60 fi # Reset when we've passed midnight so we fetch new time tomorrow if [ "$CURRENT_TIME" -ge "$MIDNIGHT" ]; then LAST_DATE="" fi + + sleep 10 done