Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit 208d1714e565d1e515d56131c1e7440e07cbfca3 @amdavidson amdavidson committed Jan 30, 2011
Showing with 42 additions and 0 deletions.
  1. +42 −0 homebrew-update-notifier.sh
42 homebrew-update-notifier.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+#
+# Notify of MacPort updates via Growl on Mac OS X
+#
+# Author: Chris Streeter http://www.chrisstreeter.com
+# Requires: Growl Notify Extra to be installed (but fails gracefully). Info
+# about how to get the extra is at http://growl.info/extras.php
+
+
+TERM_APP='/Applications/Terminal.app'
+PORT_EXEC='/opt/local/bin/port'
+GROWL_NOTIFY='/usr/local/bin/growlnotify'
+GROWL_TITLE="MacPort Update(s) Available"
+GROWL_ARGS="-n 'MacPorts' -d $GROWL_NOTIFY -a $PORT_EXEC"
+
+$PORT_EXEC sync 2>&1 > /dev/null
+outdated=`$PORT_EXEC outdated`
+
+if echo $outdated | grep -q 'No installed ports are outdated.' ; then
+ if [ -e $GROWL_NOTIFY ]; then
+ # No updates available
+ $GROWL_NOTIFY $GROWL_ARGS -m '' -t "No MacPort Updates Available"
+ fi
+else
+ # We've got an outdated port or two
+
+ # Nofity via growl
+ if [ -e $GROWL_NOTIFY ]; then
+ lc=$((`echo "$outdated" | wc -l` - 1))
+ outdated=`echo "$outdated" | tail -$lc | cut -d " " -f 1`
+ message=`echo "$outdated" | head -5`
+ if [ "$outdated" != "$message" ]; then
+ message="Some of the outdated packages are:
+$message"
+ else
+ message="The following packages are outdated:
+$message"
+ fi
+ # Send to growlnotify
+ echo "$message" | $GROWL_NOTIFY $GROWL_ARGS -s -t $GROWL_TITLE
+ fi
+fi

0 comments on commit 208d171

Please sign in to comment.