[screenshot of twit]

Twit: a lightweight Python twitter client

Twit, sadly, no longer works. Twitter changed their authentication rules and the basic authentication used by python-twitter is no more. I haven't had the time or energy to figure out how to use the new authentication; I switched to reading Twitter via Bitlbee. Sorry! Twit does still work for searching for patterns (e.g. twit -s #keyword) and I still use it for that, particularly at conferences.

Okay, so all the cool kids are doing it ... I decided to check out Twitter. Except it turns out there aren't really any decent lightweight Twitter clients on Linux; they're all based on some kind of huge infrastructure I don't otherwise need, like Mono or Adobe Air. Or else they lack basic functionality (e.g. twitux doesn't let you click on or select links).

But Ubuntu had this intriguing package called python-twitter, so I looked up the python-twitter documentation online. Wow, it's fantastically easy to use. It took me about ten minutes to a basic commandline client that prints out your current timeline, and a couple of hours to a functional Tkinter GUI client tha includes a button to switch between showing personal replies or the whole timeline. (And nearly all of that couple of hours was wrestling with Tkinter.) A few more hours (of wrestling with pygtk, after determining that Tkinter's text widget wasn't good enough) and I had a posting client too.

Anyway, here they are, unpolished but surprising usable. Of course I'll be updating them as time goes by.

You can Follow me on Twitter if you like.

Linux Planet article

I wrote an article coming out on how to write this and similar programs: Write Your Own Linux Twitter Client In Less Time Than It Takes To Find One! The bare-bones script as featured in the article is available here: twit-linuxplanet.py.

A companion script, twitref, lets you search twitter for a pattern: for instance, @yourname to see any references or replies to you. For instance, you could run it from cron and mail yourself the output.

Download the scripts


Of course, you need python, and you also need the python-twitter package. In Ubuntu 9.04 Jaunty, that's a package you can install, but in earlier releases, other distros and other OSes you may have to install Python-Twitter from here. If so, you'll also need the Python module "simple-json", probably available as a package on your Linux distro.

For the user interface, twit uses Tkinter (package python-tk on Ubuntu) while ptwit uses python-gtk (package python-gtk2). Yes, I know it's silly that they use different toolkits, but by the time I found out Tkinter's text widgets sucked for typing, I already had a lot of work into the twit user interface and didn't want to rewrite it all.

How to use

Create a file named .twit in your home directory, containing at least the following two lines:

username = "yourname"
password = "yourpassword"
(Note: if you used a version earlier than 0.2, you may have a line for passwd. Change it to password.)

Optionally, you can also configure a couple of other values there:

max_entries = 11
sleep_seconds = 300
browser_str = "firefox %s"
browser_newtab_str = "firefox -new-tab %s"

twit Features

ptwit (posting) features

(For Perl fans, Don Marti has a Perl twit script.)

Twit's license is GPLv2 or (at your option) later. Happy tweeting!

More Software
Shallowsky Home
mail me