Twitter to Growl Agent in Python

While my primary Twitter usage is on my iPhone – I sometimes get behind and would like to not have to catch up with 100 tweets at the end of the day. I’ve had Growl installed on my machine for a while now and figured it would be nice to just have some tweets appear in that.

I’m also always on the look out for reducing the number of apps I need to run, so I didn’t want to run twitterific just for its growl support. A quick search of scripts that would link twitter to growl turned up some working and not working examples in ruby [ 1 2 3 ]

And some overly complex examples in Python which do their own twitter api calling. [ 4 5 ]

I wanted to add some features, and lean on one of the well done twitter modules.

So here is another take on a twitter and growl conduit – done in python. Some of the features not seen in the others:

  • Will watch your input devices for when you are idle/away and store up tweets to show you when you return
  • Lets you designate certain users as being “sticky” so their tweets stay on screen
  • manages a cache of user profile images
  • is very lightweight (only about 100 lines of readable code)

Requirements

  • You need Growl of course
  • You need the Growl Python language bindings that are part of the SDK
  • You need the less recognized, but very well done Twitter module from Mike Verdone

Here is the script

4 comments ↓

#1 Mike Verdone on 02.16.09 at 2:24 pm

The link to the script is broken. Can you fix it? I’d like to give it a try.

#2 ptone on 02.16.09 at 3:03 pm

fixed – and improved version posted

#3 Chad on 03.25.09 at 9:58 pm

Script works great.

Do you have any interest in packaging this as an .app? I’m sure a lot of people would love to use it, but the idea of compiling code is a bit scary.

Also, is it possible for you to make it so that when you click on a growled tweet, it goes to either that user’s twitter page or the url for that tweet?

I have it setup as user agent via lingon so that it starts when I login and runs in the background. Here are installation instructions for that setup. When new versions of any of the dependent files come out, these instructions will be out of date, but the changes you’ll have to make will be obvious. I’ll assume you already have Growl installed.

  1. Download & mount: http://growl.info/file/Growl-1.1.4-SDK.dmg
  2. Copy the Bindings/python folder to your Desktop.
  3. Run these commands in the terminal:
    • cd ~/Desktop/python
    • sudo python setup.py install
    • (enter your password)
  4. Download & extract to your Desktop: http://mike.verdone.ca/twitter/twitter-1.1.tar.gz
  5. Run these commands in the terminal:
    • cd ~/Desktop/twitter-1.1
    • sudo python setup.py install
  6. Download & extract the script to your Applications folder: http://www.ptone.com/temp/twitter_monitor.zip
  7. Test the script to see if it works. Run this in the terminal:
    • python /Applications/twitter_monitor.py
  8. If everything is OK, you will start to see tweets in Growl. Hit [CONTROL]-C to quit the script.
  9. Edit twitter_monitor.py with TextEdit, scroll down till you see a spot to insert your twitter username & pw. They must be surrounded with quotes, like this:
    • user = ‘YOUR NAME HERE’
    • pw = ‘YOUR PASSWORD HERE’
  10. Save twitter_monitor.py.
  11. Download & install Lingon: http://tuppis.com/lingon/
  12. In Lingon, create a new “My Agent” with the following settings:
    • Name: com.ptone.TwitterMonitor
    • What: python /Applications/twitter_monitor.py
    • When: √ Keep it running all the time no matter what happens *
  13. Save and restart (or logout and log back in).

* I tried the “Run it when it is loaded by the system (at startup or login)” option, but tweets seemed to stop growl-ing after a few minutes. I haven’t tested “Keep it running all the time…” for that long, but it seems to be working.

#4 Chad on 04.28.09 at 2:41 pm

I’ve abandoned this script recently. The idea is good, but it’s not reliable. I regularly have problems with the same tweets being growled over and over. I assume that for it to function smoothly, there’d need to be some kind of more sophisticated history checking.

Leave a Comment