Hacking Gmail Chapter 1: Desktop Integration

Welcome to Hacking Gmail. Thanks for buying this book. If you haven’t bought it, you should. It’s very good, and once you buy it you can stop loitering around the bookstore stacks. Go on: Buy it, sit down, have a coffee. See? Comfier isn’t it? Ah. Hacking Gmail. It’s a manly hobby, and this book will tell you how. Sorry? What’s Gmail, you ask? Well, let me tell you . . . What’s Gmail? March 31, 2004. A watershed in human history. Google’s web-based e-mail service, still now at the time of this writing in Beta, and available only to people invited by other existing users, was launched. Offering a gigabyte of storage, an incredibly advanced JavaScript interface, and a series of user interface innovations, Gmail was an instant hit among those who could get access to the system. Today, more than a year later, Gmail is proving to be one of the flagship applications on the web—a truly rich application within the browser, combined with the serverbased power of the world’s leading

Hacking Gmail  Chapter 1: Desktop Integration

Desktop Integration

The first part of this book really highlights its entire theme:
that the Gmail service, although ostensibly a website, can
be dragged over to touch the desktop in ways that make
new and exciting applications possible.
The first five chapters deal with this on a very basic level, allowing you to use Gmail to its limits before delving into the nitty
gritty of code and some rather extreme uses of the system.
This chapter deals with the situations that arise when you continue to use Gmail within the browser but want to use it as your
day-to-day e-mail system. There are two areas to cover: new mail
notification and mailto: link redirection

New Mail Notification

Gmail’s great features have inspired many early adopters to move
their entire e-mail regime over to the service. But unlike other
e-mail clients, Gmail requires you to have your web browser open
to see if you have any new mail. Even with tabbed browsing, this
is annoying. The alternative is to use a new-mail notifier application. This section details some of the best notifiers, grouped by
platform. This is not a definitive list even at the time of this writing. By the time you read this, there will be even more options.
But this is a good start


Perhaps not the operating system of choice for the readers of this
book, but certainly one with a lot of users, Windows is gifted with
a wide range of Gmail integration products

Google Gmail Notifier

The first and most obvious application comes from Google itself. Their Gmail
Notifier sits in the system tray, and displays an unread mail count, and the subject
line, sender, and a synopsis of newly arriving mail, all shown in Figure 1-1. At
the time of writing, it, like Gmail itself, is in beta. Get the Gmail Notifier from
FIGURE 1-1: Google’s own Gmail Notifier in action

Mozilla Extension Gmail Notifier

Technically, this will work on any platform that can run Mozilla-based browsers, but
I’ll put Doron Rosenberg’s Gmail Notifier browser extension here (see Figure 1-2).
Although it doesn’t provide the same level of interface as a taskbar-based application, for people who spend a lot of time in their web browser, the Mozilla extension
is very convenient.
You can find the extension at http://nexgenmedia.net/extensions/

Mac OS X

OS X users have a choice of two applications, both very similar to each other, and
doing pretty much the same thing: placing the mail notification in the menu bar
at the top of the screen


Carsten Guenther’s GmailStatus (http://homepage.mac.com/carsten.
guenther/GmailStatus/) is a good example. It displays new mail counts for the
Inbox, and each individual label you might have set up, adds a hotkey to launch
Gmail in your browser, supports Growl notifications (see http://growl.info/
for more on that), and gives a hotkey to write a new message in Gmail (see Figure 1-3).
FIGURE 1-3: GmailStatus in action, with Growl notification


Nathan Spindel’s gCount (www.ocf.berkeley.edu/~natan/gcount/), shown
in Figure 1-4, is very similar indeed to GmailStatus in terms of functionality, with
perhaps two interesting additions. First, you can have a new mail count in the
dock, and second, it takes your Gmail username and password from the keychain.
This is a nice touch.

Linux, etc

People using Linux, or any other Unix-style operating system with the option to
compile things, have a whole series of potential Gmail applications to choose
from. Linux users will also find the scripting done in the later stages of this book
to be very simple to implement

Mail Notification

Jean-Yves Lefort’s Mail Notification system for Linux desktops supports Gmail
as well as most of the other common e-mail systems. You can get it from www.
nongnu.org/mailnotify/ where it is released under the GPL. According to
Lefort, it works with system trays implementing the freedesktop.org System
Tray Specification, such as the Gnome Panel Notification Area, the Xfce
Notification Area, and the KDE System Tray.


Remarkably useful for the clarity of its Python-based code, Pasi Savolainen’s
Wmgmail is intended for use with WindowMaker or fluxbox window managers
on the operating system of your choice. (If that sentence means nothing to you,
this is not for you, in other words.)
It’s a standard new mail notification app, with new mail preview added in, but it
also has one very nice feature that is perfect for the hacker: You can set it to run
another program whenever new mail arrives.
You can find Wmgmail at http://osx.freshmeat.net/projects/wmgmail/

Redirecting mailto:

Now that you have your desktop telling you when you have new mail within your
Gmail account, the only remaining integration is to ensure that clicking on a
mailto: link on a web page opens Gmail instead of your operating system’s
default e-mail client


Again, as with new mail notification, Windows users have the pick of the crop.
The Google-authored Gmail Notifier, as mentioned previously, gives you the
option to redirect mailto: links when you install it.
If you really want to, you can manually edit the Windows Registry to enact the
same effect. The website www.rabidsquirrel.net/G-Mailto/ gives a rundown
of just how to do this


Other than the Mozilla extension, at the time of this writing there is no mailto:
link diversion for the Linux desktop. But happily, by far the best way of repurposing mailto: links is to do it in the browser, and specifically in a Mozilla-based
browser, which runs on all of the platforms used in this book: Windows, OS X,
and Linux. The platforms can use Jed Brown’s WebMailCompose extension (see
Figure 1-5), installable from http://jedbrown.net/mozilla/extensions/
FIGURE 1-5: WebMailCompose in action in Firefox 1.0 on OS X                                                                        This extension also allows mailto: links to point to many other web-based
e-mail systems, should you tire of all of this coolness


GmailStatus, mentioned earlier, also has the effect of changing mailto: links
to launch Gmail instead of Mail.app. But if you don’t want to use GmailStatus,
a good example for OS X users is Gmailto, found at http://gu.st/code/
Gmailto/. Gmailto is simple to use: Just download and run it, and then go to
Mail.app’s preference panel to change the default reader application to Gmailto
(displayed in Figure 1-6) instead of Mail.app. Why the preference panel is inside
the application you no longer wish to use is beyond the reckoning of mortal men.
FIGURE 1-6: Selecting Gmailto in Mail.app’s preferences


Well worth its own section, if only because it’s really weird, the Windows software
GmailerXP —http://gmailerxp.sourceforge.net— does all of the above
but adds in a desktop version of all of the other Gmail features as well: labels,
stars, setting filters and contacts, and so on (see Figure 1-7). I’m not sure when
you would use it, but it is a brilliant example of a Gmail hack.
The second half of this book looks at how applications such as GmailerXP work
and how to make your own.

And Now . . . 

By now you should be happily using Gmail, with new mail showing up on your
desktop and mailto: links on the web causing Gmail to open, not the default
mail reader you got with the operating system. In the next chapter, you look at
using the POP interface to pull your Gmail mail down into that very reader.

What's Your Reaction?