Jan 21, 2007

Growl + Twitter Improved

I’ve got a full-blown Twitter addiction. There are plenty of ways to get my fix throughout the day: RSS, IM, SMS, Twitterriffc, or just looking at the dang site itself.



But I’m also addicted to Growl, the global notification system for Mac OS X (that Apple should be shipping with Leopard, cough). Throughout the day I have all sorts of data pouring across the bottom of my screen thanks to Growl, from incoming emails to IM status messages to completed downloads. Twitter updates would fit right in!



I’m not the first guy to have this idea. Matt Bidulph of Hackdiary put together a clever, terse Ruby script that does the job. Unfortunately, Matt’s script is a bit lacking in the features department.



So I’m breaking you off a piece of the remix with my own twitter_monitor.rb. It uses the absolute latest Twitter Ruby gem from John Nunemaker, which includes a lil’ patch from me to grab the full spectrum of data available from Twitter’s API.



My script adds the following features to Matt’s original:




  • Retrieval, caching, refreshing, and display of your friends’ user icons.

  • Use of ~/.twitter to store your username and password, as per the Twitter gem.

  • Daemonization to work around Growl’s strained relationship with cron (see the Growl forum for more on this).

  • Error checking all over the place to survive network failures, etc.



You’ll want to sudo gem install twitter daemons and make sure that growlnotify is being called from the right path before you fire this thing up. Once you do, expect a warm fuzzy feeling every 15 minutes (or whenever you set it for) as your friends’ latest musings float by.



Ahh. Twitter.

7 comments:

al3x said...

<em>This comment was imported.</em>
Author: <a href="http://cjmart.in">Chris</a><br />
Posted: 2007-01-22 20:12:28<br />
How do you set the time increment for how often you get updates?

Thanks for this.

al3x said...

<em>This comment was imported.</em>
Author: <a href="http://www.al3x.net">Alex Payne</a><br />
Posted: 2007-01-22 20:20:52<br />
Chris: you can set the "interval" variable on line 25 to the number of minutes between checks. It defaults to fifteen.

al3x said...

<em>This comment was imported.</em>
Author: Bobby<br />
Posted: 2007-02-02 22:46:57<br />
Alex, would you mind detailing a bit more of the install process? I have installed growlnotifier, installed the gem and downloaded your ruby script. How do I string the three together? And reinitialize the whole thing automatically on startup?

al3x said...

<em>This comment was imported.</em>
Author: Joe Carroll<br />
Posted: 2007-02-07 16:06:30<br />
Wow. Thanks a million Alex.

Together with this:
http://www.sauria.com/blog/2007/01/18/growlified-tweet/
and this:
http://blacktree.cocoaforge.com/forums/viewtopic.php?t=5436
it makes me very happy :-)

al3x said...

<em>This comment was imported.</em>
Author: Joe Carroll<br />
Posted: 2007-02-07 16:08:43<br />
BTW, I like your "Do you hate spammers?" question, but it won't accept any capitals, or more enthusiastic answers than just "yes".

al3x said...

<em>This comment was imported.</em>
Author: <a href="http://www.coty.ws">Coty</a><br />
Posted: 2007-03-13 18:25:41<br />
Alex,

Thanks for the script. Is the icon handling in the one linked above still working for you, though? I had to tweak just a bit. Take profile_image_url.split(".")[3] rather than [2] to get the extension and then strip the junk off that.

al3x said...

<em>This comment was imported.</em>
Author: Aaron Champion<br />
Posted: 2007-04-11 15:41:35<br />
I would really appreciate a little more instruction on how to get this set up. There seems to be a real lack of information on the net about it. :-/