Skip to main content

A few examples using growlnotify (command-line tool for Growl) to post notifications from shell script.

#!/bin/bash

# -----------------------------------------------------------------------------
# EXAMPLE 1 (http://www.oceandatarat.org/?p=265)
# -----------------------------------------------------------------------------
#
# GROWLDATE=`date +"%A, %h %d %Y %H:%m:%S %Z"`
#   This takes the current system date/time and reformats it to look like "Wednesday, Feb 16 2011 21:06:28 EST"
#
# growlnotify
#   The name of the CLI program that triggers the growl message.
#
# -s
#   Set the notification as sticky.
#
# -a terminal
#   Set the notification icon the same as the icon used by Terminal.app
#
# -t "Transfer Complete"
#   The title of the notification.
#
# -m "${GROWLDATE}"
#   Set the notification message to the date string created earlier

GROWLDATE=`date +"%A, %h %d %Y %H:%m:%S %Z"`
growlnotify -s -a terminal -t "Transfer Complete" -m "${GROWLDATE}"

# -----------------------------------------------------------------------------
# EXAMPLE 2
# -----------------------------------------------------------------------------
#
# growlnotify
#   The name of the CLI program that triggers the growl message.
#
# --image <path>
#   Sets the notification icon to contents of the given image file.
#
# -s
#   Set the notification as sticky.
#
# -t "WebDev Repos Updated"
#   The title of the notification.
#
# -m "All webdev repots have been updated."
#   The notification message.

growlnotify --image "$HOME/Scripts/growlnotify/img/32x32/download.png" -s -t "WebDev Repos Updated" -m "All webdev repos have been updated."