Vytautas Liuolia (or Vytas, for short) is one of the Google Summer of Code students, being jointly mentored by Matthias Clasen and me. He’s working on a library to make single instance applications easy to write. Basically, all existing “solutions” to this problem in the Gnome world (and there are many) are wrought with bugs. We need to make it easy to do the right thing in order to get apps to actually work right, and Vytas is working on that for us.
While I would like to claim that this is merely an application problem, and that our base system is a shining example of getting everything right (in particular because I have put a lot of my own time into trying to make it so), such is simply not the case. Vytas has had the “pleasure” of learning all kinds of nasty X details, scouring various freedesktop.org specifications, and becoming familiar with some of the guts of both gtk+ and metacity. Some of his fun has included dealing with race conditions and making things robust and backwards compatible even when faced with apps/libraries/window-managers/toolkits (yes, we make him worry about all that stuff) which use obsolete versions of the specifications.
He has been patching metacity and gtk+ to provide extra functionality needed by the library so that it can do its work without exposing too many ugly implementational details to the programmer or requiring any hacks of them. But even better than that, today he uncovered a focus handling bug with new windows that has been in metacity for years now. I had gotten complaints over the years so I knew there was an issue, and in trying to track it down I had read over the code many times trying to figure out what could possibly go wrong (I had never been able to duplicate the problem myself). I even created various patches to increase the debugging spew for others to use, but to no avail. However, the bug is finally dead now. So very, very dead. Just the way we like ’em.
Rock on, Vytas.
 The library may become part of gtk+ or some other gnome library, but we don’t know where it’ll end up yet.
 For example, there’s bacon, which was actually meant to be a general library for this. There are lots of other building blocks used as a base for building such an app, such as sockets, X messages, bonobo, and D-Bus. And there are various tutorials out there on how to use those building blocks to construct such a program. It is not uncommon for various apps to switch which building blocks they use occasionally in their particular hand-rolled version of this functionality.
 I’m not exaggerating. They all suck. They all handle the basics okay, but do not handle startup notification correctly and thus feel buggy and non-integrated — unless someone has manually patched the relevant program. Manually patching the relevant program is an annoyingly difficult exercise, as it requires pretty detailed knowledge of how startup-notification and focus handling with timestamps work, learning an entirely new single instance mechanism in many cases (really, nearly each and every app does it differently) and producing some ugly, hacky, difficult to understand patches. Sometimes, quite understandably, even hackier workarounds or incomplete patches are used instead.
Update: Only three mistakes found so far in the original — typos in both Matthias’ and Vytautas’ names, and an incorrect statement about gedit. Can anyone spot any more?