Gmail, Conky, and libnotify

Several years ago I discovered a fantastic system monitor named conky. Over the years I've been tweaking my .conkyrc and it has really evolved into a little command center all on it's own. However, I read my e-mail through a mutt, and thus to check it I have to open mutt and look and see if I have any new mail. This is often obnoxious, because I'll either forget to check and miss something until later, or I'll check a lot and not get any e-mail. Today it occurred to me "hey, computers are good at repetitive tasks!", so I decided to automatically check my e-mail and render the results in conky. I also have heard lots of noise about libnotify, and how wonderful it is, so I decided to use that as well. The result is a script which checks a user's Gmail (using a password stored in a keyring), updates conky, and shows a libnotify notification if necessary. It also supports querying of arbitrary Gmail labels, allowing you to display unread counts for other e-mail addresses you might possibly have mapped to your Gmail account.

You can get your own copy to play around with if you like. It's fairly well documented, but I'll answer any questions anyone has. The dependencies (at least on Ubuntu) are python-notify python-keyring and your favorite of: python-keyring-gnome or python-keyring-kwallet.

I've released it under a beerware style license, in hopes that someone, somewhere, might find it useful. Feedback is appreciated!

gdwarf @ 2011-01-23 09:02:44:

Thanks for this script! It's great! I found enough scripts checking for Gmail but none worked with google apps, and this works like a charm! Nat, I had the same errors as you did. The reason was that I copied the config file straight from the script. Apparently any comment that is not at the beginning of the line is not seen as a comment. If you remove all comments and unnecessary whitespace from the config file, the script should work!

Nat @ 2010-12-01 03:29:56:

This script looks ideal for my purposes - no more gmail systray applets with silly memory footprints ;-) However, I'm having problems getting it working: Traceback (most recent call last): File "/usr/local/bin/gmail_unread.py", line 157, in <module> messages = get_unread(label) File "/usr/local/bin/gmail_unread.py", line 145, in get_unread dom = parse(urllib2.urlopen(req)) File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen return _opener.open(url, data, timeout) File "/usr/lib/python2.7/urllib2.py", line 389, in open req = meth(req) File "/usr/lib/python2.7/urllib2.py", line 1076, in do_request_ raise URLError('no host given') I can't figure it out, I've verified the keyring is retrievable with keyring.get_password("gmail","me@gmail.com"), so its not that. Any ideas?

tycho @ 2010-08-05 13:57:58:

Indeed. I haven't done any development on this for a while (plus, I need to clean up the code so I can actually release it). Perhaps some sort of RSS/Atom feed is in order!

me @ 2010-08-04 21:51:03:

Perhaps this means there will be a notification feature added to *this* website so people can subscribe to updates?