Twitter on your desktop in three lines of Python.

It’s nice when things come together. I’ve been sick with envy watching the Lifehacker ‘featured desktop’ posts. All these awesome looking linux desktops, they’re like Audis… sexy as all get-out, but have fun getting them serviced.

Then a couple days ago a Mac OS desktop made the cut, alerting me to GeekTool’s revival. Apparently, GeekTool fell off when Apple went Intel and it’s taken them a while to get things back together. It’s a fairly simple BlitThingsOntoTheDesktop utility that gets the job done.

Well. I wanted the date. My friend Dave wanted to see the date at a glance so badly he resorted to changing his system’s default date format to make the date appear in the menubar. Turns out it has a few icky consequences.

So I throw the date in GeekTool. (Instructions and inspiration here.)

What else? Twitter.

I don’t really like twitter clients much. Tweetie is awesome, but I dunno. It’s always… there. I don’t like many of the ‘not _really_ there’ technologies for getting updates like this either (Growl. grrr.)

So it’s settled. What will it take to get my twitter feed on my desktop?

Turns out, fifteen minutes and about three lines of Python.

import twitter
import os, sys
import textwrap
import string

api = twitter.Api(username = "royalgeoffrey", password = "royalgeoffreyssupersecretpassword")

for s in api.GetFriendsTimeline():
	print textwrap.fill(
		"%s%s" % (string.ljust(s.user.screen_name + ":", 22), s.text),
		subsequent_indent="                      "


download source

That’s it. And really, most of the complexity there is in formatting the output nicely for display at the command line.

Want it? Take it! Substitute your own username and password. You’ll need the python-twitter and simplejson modules. Then set up a GeekTool shell command to run python ~/royalgeoffreycelebritybicycle/ (assuming you copy the above python source and save it to ~/royalgeoffreycelebritybicycle/

Set it to refresh as often as your comfortable with, and off you go. The results look something like this:


I dig it. Beats refreshing the website every time I get bored, or running yet another app that eats up screen real estate.

At any rate. If you’re not versed in dealing with Python modules, and the like.. don’t fret. There’s more coming. Big Plans. Keep watching. I’ll be rolling out some nicer, cleaner, prettied-up stuff based on this idea in the near future.

One Comment

  1. Shea
    Posted May 29, 2009 at 8:50 pm | Permalink

    I knew someone would copy conky and the mac fan boys would get boners. Good works, looks great!

One Trackback

  1. [...] crash early, crash often. Some good advice in here. I really dig the name Offensive Programming.Twitter on your desktop using GeekTool and Python.GeekTool is a PrefPane (OS X) to show system logs, unix commands output, [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *