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.

Usage

Run this script once to set up the scheduled hybrid update agent. The script will guide you through choosing a schedule interactively.

# Set up the scheduled hybrid auto-update agent
./setup-hybrid-notifications.sh

After setup, manage the agent with these commands:

# Verify the hybrid agent is loaded
launchctl list | grep com.homebrew.hybridautoupdate

# Manually trigger a hybrid update right now
launchctl kickstart gui/$(id -u)/com.homebrew.hybridautoupdate

# Stop scheduled hybrid updates
launchctl bootout gui/$(id -u)/com.homebrew.hybridautoupdate

# Resume scheduled hybrid updates
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.homebrew.hybridautoupdate.plist

What Gets Changed

  • LaunchAgent plist — A new file is created at ~/Library/LaunchAgents/com.homebrew.hybridautoupdate.plist (unless you choose manual only). It tells launchd when to run the hybrid auto-update script.
  • launchd registration — The plist is registered with launchctl bootstrap gui/$(id -u), activating the schedule immediately. The agent stays active across restarts until you boot it out.
  • auto-update-brew-hybrid.sh — The email address and phone number you enter are written into its EMAIL_ADDRESS and PHONE_NUMBER lines.
  • Setup log — Written to ~/Library/Logs/HybridNotificationSetup.log.

The script does not touch system files. Apart from the one test run, all update and notification work is done by auto-update-brew-hybrid.sh when launchd triggers it.

Related Scripts

  • Schedule Auto-Updates — The equivalent scheduling script for the basic (text-only) auto-update. Choose this if you only want text message notifications without email reports.
  • Auto-Update with Email & Text — The hybrid auto-update script that this scheduling agent triggers. Read its documentation to understand exactly what happens during each scheduled run, including the email and text notification details.