Quantcast
Viewing all articles
Browse latest Browse all 4

Homebrew Package Update Notifications via Growl

Over the weekend, I finally upgraded my system to Mac OS Lion. I also took the opportunity to do a completely fresh install of my system, doing a final TimeMachine backup before erasing the hard drive and then installing Lion off a USB thumb drive.

I have long used MacPorts as my open source package manager, but I've had issues recently with certain ports not being updated or being out of date. So I was really interested in Homebrew. The fact that it is all on github, open and actively developed really appealed to me. After getting it up and running, I wanted to port my package update notifier to use Homebrew. Doing so was really quite easy. Here's what I came up with, which is also in my dotfiles on github:

#!/bin/bash## Notify of Homebrew updates via Growl on Mac OS X## Author: Chris Streeter http://www.chrisstreeter.com# Requires: Growl Notify Extra to be installed. Install with#   brew install growlnotifyTERM_APP='/Applications/Terminal.app'BREW_EXEC='/usr/local/bin/brew'GROWL_NOTIFY='/usr/local/bin/growlnotify'GROWL_TITLE="Homebrew Update(s) Available"GROWL_ARGS="-n 'Homebrew' -d $GROWL_NOTIFY -a $BREW_EXEC"$BREW_EXEC update 2>&1 > /dev/null
outdated=`$BREW_EXEC outdated | tr ' ''\n'`if[ -z "$outdated"] ; then    if[ -e $GROWL_NOTIFY]; then# No updates available$GROWL_NOTIFY$GROWL_ARGS -m '' -t "No Homebrew Updates Available"fielse# We've got an outdated formula or two    # Nofity via growlif[ -e $GROWL_NOTIFY]; thenlc=$((`echo"$outdated" | wc -l`))outdated=`echo"$outdated" | tail -$lc`message=`echo"$outdated" | head -5`if["$outdated" !="$message"]; thenmessage="Some of the outdated formulae are:$message"elsemessage="The following formulae are outdated:$message"fi# Send to growlnotifyecho"$message" | $GROWL_NOTIFY$GROWL_ARGS -s -t $GROWL_TITLEfifi

Assuming the script is at ~/bin/brew-update-notifier, you can install the script to a crontab by running sudo crontab -e, then adding the line 0 12 * * * /Users/<username>/bin/brew-update-notifier to the end of the file (substituting <username> for your username, or wherever you've put the script). I've chosen to run the script every day at noon because my computer is likely to be on and connected to a network.


Viewing all articles
Browse latest Browse all 4

Trending Articles