What This Script Does
The setup-hybrid-notifications.sh script creates a macOS LaunchAgent that automatically triggers the hybrid auto-update script on a recurring schedule. This is the companion scheduling script for auto-update-brew-hybrid.sh, and it is the recommended way to set up fully automated Homebrew maintenance with comprehensive notification support. Once configured, your Mac will keep all Homebrew packages up to date in the background and notify you via both email and text message whenever updates are applied.
This script works identically to the basic scheduling script (setup-auto-update.sh) in terms of its scheduling mechanism. The only difference is which auto-update script it targets. Where the basic scheduler points to auto-update-brew.sh (text-only notifications), this scheduler points to auto-update-brew-hybrid.sh (email and text notifications). Everything else — the interactive schedule selection, the plist generation, the launchd registration — follows the same process.
When you run the script, it asks for your email address and phone number, tests each, and writes them into EMAIL_ADDRESS and PHONE_NUMBER at the top of auto-update-brew-hybrid.sh. It then offers three schedules: weekly on Sunday at 2:00 AM (recommended), daily at 2:00 AM, or manual only (no agent is created). The plist is written to ~/Library/LaunchAgents/com.homebrew.hybridautoupdate.plist and registered with launchctl bootstrap gui/$(id -u), which activates the schedule immediately.
The LaunchAgent uses a different identifier than the basic scheduling agent, which means you can run both side by side if you want. However, this is not recommended — running two separate auto-update agents would mean your packages get updated twice as often, which is unnecessary and doubles the notification volume. If you are switching from the basic scheduler to the hybrid one, first stop the basic agent with launchctl bootout gui/$(id -u)/com.homebrew.autoupdate, then run this script.
Like all launchd agents, the scheduled task created by this script persists across restarts and login sessions. It runs under your user account and does not require administrator privileges. If your Mac is asleep when the scheduled update time arrives, launchd runs the update when it wakes; if it is shut down, that run is skipped until the next scheduled slot. The plist configuration includes the StartCalendarInterval key, which is the launchd equivalent of a cron schedule expression.
Email reports are sent with the command-line mail -s through macOS's built-in postfix, not through the Mail app. macOS leaves postfix switched off, so email only works once you have configured it with an SMTP relay. Without one, the setup's test email fails with a clear message and the hybrid script logs "Email NOT sent" on each run instead of delivering reports. Text summaries go through the Messages app via AppleScript, so Messages must be signed in to iMessage and your terminal must be allowed to control it (System Settings > Privacy & Security > Automation). WIFI_NETWORK is not set by this script: edit it at the top of auto-update-brew-hybrid.sh; left as the placeholder, every run skips.
If you later decide you want to change the schedule, simply run this script again. It removes the existing agent with launchctl bootout, writes a fresh plist with your new choice, and bootstraps it again. Before finishing, it runs auto-update-brew-hybrid.sh once as a test; that run is real and upgrades packages if the Wi-Fi and power conditions are met. Use --dry-run to preview without changing anything.