generated from me/template-mit
Improve the notification message and frequency.
This commit is contained in:
1 parent
1fc42b4e4e
commit
b0acb7793a
1 file changed
+8
-5
+8
-5
@@ -94,8 +94,12 @@ fetch_sunset_time() {
|
|||||||
# Show alert via fallback chain: fyi -> notify-send -> wall
|
# Show alert via fallback chain: fyi -> notify-send -> wall
|
||||||
###############################################################################
|
###############################################################################
|
||||||
show_alert() {
|
show_alert() {
|
||||||
TITLE="Sunset Alarm"
|
ALERT=$(date -d @${ALERT_WINDOW_START} +"%H:%M")
|
||||||
MESSAGE="Sunset is at $(date -d @${SUNSET_EPOCH} +"%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"
|
persistent="-t 0 --wait"
|
||||||
icon="-i weather-clear -u critical"
|
icon="-i weather-clear -u critical"
|
||||||
@@ -159,13 +163,12 @@ while true; do
|
|||||||
if [ "$CURRENT_TIME" -ge "$ALERT_WINDOW_START" ] && \
|
if [ "$CURRENT_TIME" -ge "$ALERT_WINDOW_START" ] && \
|
||||||
[ "$CURRENT_TIME" -lt "$MIDNIGHT" ]; then
|
[ "$CURRENT_TIME" -lt "$MIDNIGHT" ]; then
|
||||||
show_alert
|
show_alert
|
||||||
sleep 5 # Re-alert every 5 minutes while in alert window
|
|
||||||
else
|
|
||||||
sleep 60
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Reset when we've passed midnight so we fetch new time tomorrow
|
# Reset when we've passed midnight so we fetch new time tomorrow
|
||||||
if [ "$CURRENT_TIME" -ge "$MIDNIGHT" ]; then
|
if [ "$CURRENT_TIME" -ge "$MIDNIGHT" ]; then
|
||||||
LAST_DATE=""
|
LAST_DATE=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
sleep 10
|
||||||
done
|
done
|
||||||
Reference in new issue
Block a user