generated from me/template-mit
ASked agent to fix the program using sunset time rather than midnight. Seems to be working properly now.
This commit is contained in:
1 parent
ffc29eabb2
commit
fae03c94d9
1 file changed
+7
-4
+7
-4
@@ -149,17 +149,20 @@ while true; do
|
||||
# Calculate alert window start (sunset minus specified minutes)
|
||||
ALERT_WINDOW_START=$(( SUNSET_EPOCH - (MINUTES * 60) ))
|
||||
|
||||
# Alert while current time is within the window (from window start until sunset)
|
||||
# Calculate midnight of the current day
|
||||
MIDNIGHT=$(date -d "${TODAY} +1 day" +%s)
|
||||
|
||||
# Alert while current time is within the window (from window start until midnight)
|
||||
if [ "$CURRENT_TIME" -ge "$ALERT_WINDOW_START" ] && \
|
||||
[ "$CURRENT_TIME" -lt "$SUNSET_EPOCH" ]; then
|
||||
[ "$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 sunset so we fetch new time tomorrow
|
||||
if [ "$CURRENT_TIME" -ge "$SUNSET_EPOCH" ]; then
|
||||
# Reset when we've passed midnight so we fetch new time tomorrow
|
||||
if [ "$CURRENT_TIME" -ge "$MIDNIGHT" ]; then
|
||||
LAST_DATE=""
|
||||
fi
|
||||
done
|
||||
Reference in new issue
Block a user