Archive for the 'Mac' Category

Growl at the Devel: Using notifications to smooth workflow.

In these times of Agile development, super tight deadlines, and personal multitasking responsibilities that would make the latest Cray Supercomputer weep, every little tool that helps manage your workload is a blessing. Even more so if implementing and using said tool is simple and intuitive.

If you are more than just a casual user of MacOS X, then most likely you have heard of Growl. If you haven't, it is a highly configurable, unobtrusive notification system that gives application developers access to a simple API that they can tie into, instantly enabling notification functionality. For instance, there are add-ons for Firefox and Thunderbird that inform you when your download is finished or you have new email, plugins for iTunes that easily display current track info when the song changes, and even a plugin that updates you what is going on with your character and friends in Second Life.

You may think "This is all well and good, but how does it help me at work?" Well, there is a little known extra that is included with the Growl package (in the Extras folder of all places) called growlnotify. It is a fairly simple and straight forward command line interface for sending Growl notifications. After installing and configuring Growl in your System Preferences, then building and installing growlnotify, open a terminal and try the following:

growlnotify -t "Hello from Growl" -m "Nice to meet you"

If everything is set up correctly, you should see something like this:

(the style and position will depend on how you set your preferences, but you get the idea)

So how is this useful? Well, I was looking for a quick and simple way to get notified whenever a developer made a commit to the Subversion server. Setting up SVN to email me would be a bulky task, and either checking the web interface, GUI front ends, or using the SVN command line tools would have to be an interactive step on my part.

That's when I remembered growlnotify. After a read through of the man page, a quick and dirty shell script, and a little help from my old friend cron, I had pretty much what I needed:


#!/bin/bash

localrep=`dirname $BASH_SOURCE`
URL=`svn info $localrep 2>/dev/null | sed -ne 's#^URL: ##p'`
there=`svn info $URL 2>/dev/null | sed -ne 's#^Last Changed Rev: ##p'`
here=`svn info $localrep 2>/dev/null | sed -ne 's#^Revision: ##p'`
blame=`svn info $URL 2>/dev/null | sed -ne 's#^Last Changed Author: ##p'`

if [ $there -gt $here ] ; then
growlnotify -t "SVN Commit by $blame" -m "Local: $here - Remote: $there"
fi


Elated with the success of my elegantly simple solution, I started thinking up other uses for my new found favorite tool. After a few neat but overall useless and unproductive ideas, it dawned on me.

Builds!

So now that Growl has informed me that there is new code waiting, it's time to update my local source tree, build, and deploy for testing. Depending on what part of the project I'm working on, this process could take anywhere from 5 to 20+ minutes and include a any number of steps and scripts. Sure, I could just keep switching back and forth to the terminal to check if the build is done, but why? I can just end all of my build scripts with one simple line:



growlnotify -t "Build is done" -m "Get to testing"


And with that one line,  I no longer have to babysit a terminal of scrolling text. Now I'm free to spend that time reading the relevant design documents, check the bug tracker, catching up on the progress of other developers, *cough*check Slashdot*cough*, et cetera. When the computer is done doing it's thing, it will inform me without any intervention on my part.

Conclusion

Growl and growlnotify are not huge software packages of paradigm shifting, buzzword bingo winning, manager wowing life changers. They are a pair of simple tools to make your development life just a little bit easier, and are easy to grok with a simple one time read through of the man page. These two examples are just quick and easy ways for you to start working with notifications, there are many more possible ways to utilize these tools in your workflow.

Happy hacking!

Comments

Installing swftools on Mac OS X Leopard

Some time has passed since my last swftools install documented in this blog post. Two important things have happened since then, first Apple came out with a new OS 10.5 Leopard and swftools is now included under fink. Fink is a utility that allows for the pain free installation of open source *nix software under Darwin. To get swftools running under Leopard we need to first install fink and then use fink to install swftools.

This post would be almost over if fink were available as a binary package for Leopard. Unfortunately at the time of writing in order to get fink running on 10.5 we need to compile it from source. Make sure to check the fink site to see if a binary package has been released for Leopard. To download the source code go to the download section of the fink site located here. I'll be using the latest version, which is fink-0.28.1. Ok let's get started:

1. Make sure you have XCode installed.

2. Go to the directory where you downloaded fink and extract the downloaded archive by running the following command
tar xzvf fink-0.28.1.tar.gz

3. Go to the newly extracted fink-0.28.1 directory.

4. Run the command ./bootstrap.

5. Fink needs root privileges to be installed, when prompted which method to use I chose sudo, which is the default selection [1]. You will then need to enter your password.

6. The installer offers the option of selecting where you would like to install fink. I just left the default location /sw.

7. You will get asked a couple dozen questions to which you could safely leave the default values by hitting the enter key. The important one to change is when the installer prompts you about the "unstable" tree. It is very important that you answer Y so that packages from the "unstable" tree are included with fink. Swftools is currently a part of that tree in version 0.8.1-2.

8. Once everything is done compiling and linking run

fink selfupdate

and leave the default selection of using rsync for the self update method.

9. Now it's time to install swftools. Just run the command

fink install swftools

You will be notified that 16 additional required packages will be installed. Just hit enter to install all of them.

10. Swftools 0.8.1-2 are now installed in /sw/bin/ or whatever directory you specified in step 6.

To verify that you have swftools installed correctly just run /sw/bin/pdf2swf --version. You should see output similar to the one below:

pdf2swf - part of swftools 0.8.1

Hopefully soon enough there will be a binary package for fink so the install will be much simpler.

10 Comments