Universal Back Button (UBB) is a simple app that implements a back button that in principle "works everywhere." The idea came from Oliver Boermans, in a blog post titled "The universal back button," in response to Brent Simmons' post on "Apps that work together." (See where I got the name?) The idea is to provide a back button that takes you back to the task you were working on, before you opened a file, clicked a link, or similar. The idea intrigued me, and I started wondering how one might go about implementing such a thing for Mac OS X. Oliver and Brent both discuss this in the context of URLs, musing over using the referrer field or similar to achieve the effect. Nothing on Mac OS X supports this - at least for now - but we do have something similar, and the mechanism has its roots way back in System 7 (or maybe even further back?). It's called Apple Events, and it's the mechanism the window system uses to tell applications which files or URLs to open. (Apple Events have many other uses too, of course, but they are beyond the scope of this app - and this blog post!) Now if only there were a way to tap into the stream of Apple Events flowing between applications. Unfortunately, no straightforward way exists - at least none that is documented - but Apple have included a nice debug facility that can be enabled on a per-application basis. It is activated by setting a number of environment variables prior to launching the application in question. In particular, UBB sets the AEDebugReceives environment variable, thus causing any app that receives an Apple Event to dump it to the console log. By continuously analyzing the output from the console log, UBB can infer which app caused a different app to open a file or link, and thus create a "back relation" to the app. For instance, when I click a link in iChat, a "GURL" Apple Event is sent to my default web browser (Safari, FIrefox, etc.). UBB notices this, and when you click the universal back button in your menubar, UBB switches you right back to iChat. Of course, the mechanism has some drawbacks. For instance, there is no association between different windows - the association only exists between different apps. So if you have several windows open in iChat, the UBB won't necessarily bring you back to the window that sent you to Safari in the first place. But, we have to start somewhere, and this is as good a starting point as any. To make the mechanism permanent, and work for all the apps that you open, the environment variable has to be set for all applications that you launch. I fiddled with a few different options, notably trying to set the environment variables on both the Finder and the Dock (after restarting them) to avoid the "you have to log out for changes to take effect" drawback, but found that the best and simplest solution was to just set the environment variable in the Mac OS X sanctioned way: By adding an entry to the environment.plist file located in a directory called .MacOSX in your home directory. Of course, while you are free to use the app as it stands, I have also made the source code available under the BSD license. Feel free to tinker with it, send me changes, or just give suggestions on improvements. Happy hacking! Update May 27th: I just posted version 1.0.1 to fix a small bug in the state parsing code. Source updated too. Comments by Disqus
|
About me ![]() ![]() Contact me Recent posts 2011 Jul 28: Running iTunes in a debugger (gdb) Jul 25: The /Volumes/MobileBackups directory Jul 20: FolderGlance 3.0.1 supports Lion Mar 03: Quick tip: Speeding up Xcode compilations Mar 02: FolderGlance 3.0 Jan 07: Making Universal Back Button work on 10.6.5 and later 2010 Sep 03: Creating pthreads in C++ using pointers to member functions May 31: Quickly open URLs in Terminal May 31: Snow Leopard and automatically submitted Crash Reports May 27: Universal Back Button released for Mac OS X May 22: The 22 Megapixel Laptop Feb 09: FolderGlance on MacUpdate Promo 2009 Sep 28: FolderGlance 2.5.3 is out Sep 21: FolderGlance 2.5.1 adds features and fixes bugs Sep 16: FolderGlance 2.5 released! Sep 10: Intriguing: Snow Leopard ships with the iPhone's multi-touch API built-in Sep 03: FolderGlance and Snow Leopard Mar 15: Fixing Keynote '08 and '09 to work with the Scripting Bridge Feb 26: A website in an image Feb 09: Display wall multi-touch 2008 Feb 19: Spaces.. Spaces.. Spaces.. retires Feb 08: How-to: Reverse engineering the Dock to fix Spaces Jan 25: Interacting with wall-sized displays 2007 Dec 20: Interesting Finder bug Dec 06: Developing applications for the iPod touch (and the iPhone) Nov 15: Spaces.. Spaces.. Spaces.. and 10.5.1 Nov 15: Thread creation using pthread_create() on Leopard Nov 13: Spaces.. Spaces.. Spaces.. Nov 07: FolderGlance, Leopard and the More... menu Nov 06: FolderGlance and Screen Sieve now also on Leopard! Sep 16: Mysterious window server hangs Archive RSS feed Links |