-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdispatch.sh
More file actions
43 lines (40 loc) · 1.05 KB
/
dispatch.sh
File metadata and controls
43 lines (40 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
#
# dispatch.sh - Wellbeing nudge dispatcher
#
# Called by LaunchAgent/cron at scheduled times.
# Routes to the correct Python script based on current hour.
#
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PYTHON_BIN="${PYTHON_BIN:-python3}"
HOUR=$(date +"%H")
DOW=$(date +"%u") # 1=Monday, 7=Sunday
log() {
echo "[wellbeing $(date +%H:%M:%S)] $1"
}
case "$HOUR" in
07)
log "Morning nudge"
"$PYTHON_BIN" "$SCRIPT_DIR/morning-nudge.py"
;;
08)
log "Morning followup"
"$PYTHON_BIN" "$SCRIPT_DIR/morning-nudge.py" --followup
;;
19)
log "Evening wind-down"
"$PYTHON_BIN" "$SCRIPT_DIR/evening-nudge.py"
# Sunday = weekly check-in
if [ "$DOW" = "7" ]; then
log "Weekly check-in (Sunday)"
"$PYTHON_BIN" "$SCRIPT_DIR/weekly-checkin.py"
fi
;;
23)
log "Bedtime nudge"
"$PYTHON_BIN" "$SCRIPT_DIR/evening-nudge.py" --bedtime
;;
*)
log "No scheduled action for hour $HOUR"
;;
esac