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 guides you through selecting your preferred update schedule. You choose the frequency (daily, weekly, or on a specific day) and the time of day. The script then generates a launchd plist file that encodes your schedule preferences in the XML format that macOS expects. The plist is written to ~/Library/LaunchAgents/ and loaded into launchd, 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 scheduler, the recommended approach is to first unload the basic agent, then set up the hybrid agent. The script's documentation explains how to do this.

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 or off when the scheduled update time arrives, launchd will run the update the next time your Mac wakes up or boots, ensuring no scheduled runs are permanently missed. The plist configuration includes the StartCalendarInterval key, which is the launchd equivalent of a cron schedule expression.

Before running this script, make sure you have configured both your email address and phone number in the Brew Scripts configuration file. The hybrid auto-update script uses both of these settings for its dual notification system. If either is missing, the corresponding notification channel will be silently skipped during each update run, which partially defeats the purpose of using the hybrid variant. You should also verify that your Mail.app has at least one active email account configured, since the email notifications are sent through Mail.app's AppleScript interface.

If you later decide you want to change the schedule, simply run this script again. It detects the existing plist, unloads the current agent, generates a fresh plist with your new preferences, and reloads it. You do not need to manually edit XML files or remember arcane launchctl commands. To stop scheduled updates entirely, you can unload the agent with a single terminal command, and to resume you simply load it again.

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 brewscripts

# Manually trigger a hybrid update right now
launchctl start com.brewscripts.autoupdate-hybrid

# Stop scheduled hybrid updates
launchctl unload ~/Library/LaunchAgents/com.brewscripts.autoupdate-hybrid.plist

# Resume scheduled hybrid updates
launchctl load ~/Library/LaunchAgents/com.brewscripts.autoupdate-hybrid.plist

What Gets Changed

  • LaunchAgent plist — A new file is created at ~/Library/LaunchAgents/com.brewscripts.autoupdate-hybrid.plist. This XML configuration file tells launchd when and how to run the hybrid auto-update script.
  • launchd registration — The plist is loaded into launchd via launchctl load, activating the schedule immediately. The agent remains active across restarts until explicitly unloaded.

This script does not modify Homebrew packages, system files, or your configuration file. It exclusively handles the creation and registration of the launchd scheduling agent. All update and notification work is delegated to the auto-update-brew-hybrid.sh script 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.