⚙️ Automation
Notification Alert System
Set up automated notifications for system events, file changes, and scheduled reminders
★☆☆ Beginner 15 min January 13, 2025
Use Case
Staying informed about important events without constant monitoring is essential. Cowork can help set up notification systems that alert you when specific conditions are met.
Example Prompt
I want to set up automated notifications on my Mac. Please create:
1. File monitoring:
- Alert when any file is added to ~/Downloads
- Alert when ~/Documents/Important changes
2. System alerts:
- Notify if disk usage exceeds 80%
- Alert when a specific process stops
3. Scheduled reminders:
- Daily standup reminder at 9:45 AM
- Weekly backup reminder on Sundays
Create the scripts and launchd configurations. Save to ~/Scripts/notifications/
What Cowork Does
- Monitor Setup: Creates file and system watchers
- Alert Configuration: Sets up native notifications
- Schedule Definition: Creates launchd/cron jobs
- Script Generation: Writes monitoring scripts
- Documentation: Provides setup instructions
Sample Output
#!/bin/bash
# download_watcher.sh - Monitor Downloads folder
WATCH_DIR="$HOME/Downloads"
LOG_FILE="$HOME/Scripts/notifications/download.log"
fswatch -0 "$WATCH_DIR" | while read -d "" event; do
filename=$(basename "$event")
# Skip partial downloads
if [[ "$filename" == *.crdownload ]] || [[ "$filename" == *.part ]]; then
continue
fi
# Skip hidden files
if [[ "$filename" == .* ]]; then
continue
fi
# Send notification
osascript -e "display notification \"$filename\" with title \"New Download\" sound name \"Glass\""
# Log the event
echo "$(date '+%Y-%m-%d %H:%M:%S') - New file: $filename" >> "$LOG_FILE"
done
#!/bin/bash
# disk_check.sh - Monitor disk usage
THRESHOLD=80
# Get disk usage percentage (macOS)
USAGE=$(df -h / | awk 'NR==2 {gsub(/%/,""); print $5}')
if [ "$USAGE" -gt "$THRESHOLD" ]; then
osascript -e "display notification \"Disk usage at ${USAGE}%\" with title \"Warning: Disk Space\" sound name \"Basso\""
# Optional: Open Finder to help clean up
# open ~/Downloads
fi
#!/bin/bash
# standup_reminder.sh - Daily standup reminder
osascript <<EOF
display dialog "Daily Standup in 15 minutes!
Prepare:
- What I did yesterday
- What I'm doing today
- Any blockers" with title "Standup Reminder" buttons {"Dismiss", "Open Notes"} default button "Dismiss"
if button returned of result is "Open Notes" then
tell application "Notes" to activate
end if
EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- com.user.standup-reminder.plist -->
<key>Label</key>
<string>com.user.standup-reminder</string>
<key>ProgramArguments</key>
<array>
<string>/Users/you/Scripts/notifications/standup_reminder.sh</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>9</integer>
<key>Minute</key>
<integer>45</integer>
</dict>
<key>RunAtLoad</key>
<false/>
</dict>
</plist>
Installation
# Install fswatch for file monitoring
brew install fswatch
# Load launchd services
launchctl load ~/Library/LaunchAgents/com.user.standup-reminder.plist
launchctl load ~/Library/LaunchAgents/com.user.disk-check.plist
# Start download watcher in background
nohup ~/Scripts/notifications/download_watcher.sh &
Tips
- Use native notifications for important alerts
- Consider integrating with Slack/Discord for remote alerts
- Keep notification frequency reasonable
- Add sound for critical alerts