Dropbox App Sync Icon

Joe Workman put out a utility today for sharing Application Support folders between machines using Dropbox. It uses symlinks to allow moving the folder out of ~/Library/Application Support and into your Dropbox but keeping it accessible to the application. This is a great trick, and the Joe’s utility makes it dead simple to pull off. The biggest concern, however, is the possibility of corruption and other issues if you run the application on multiple machines simultaneously.

As Joe said on Twitter, Dropbox has great versioning and you can recover pretty easily. I started thinking, though, about a way to script the launch of an application such that it would shut down any remote counterparts before launching. I haven’t figured out the solution yet, but I thought I’d put some ideas out there to see if anyone had the missing puzzle pieces.

My basic approach would be a combination of shell scripting (SSH) and AppleScript (osascript). AppleScript’s quit command allows the remote application to shut down cleanly, and many applications accept the saving yes parameter to save open files without asking. Not enough of them, though, and if an unsaved file asks to be saved, it can hang a remote osascript call indefinitely.

You can force quit (kill) an app easily, but that doesn’t really provide the clean exit you want before the application data is synced. You can also pause (kill -STOP) an app, but again, that leaves too much data unwritten, and when it’s unpaused could just cause further sync conflicts.

Launching the script is easy enough with LaunchBar or Quicksilver (or even an applet), but I was thinking about actually modifying the app bundle to make it effortless. If you go into the applications OS X binary folder, you can rename the binary and replace it with an executable shell script that runs your “remote quit” process before calling the renamed original. It’s not proofed against updates and is easily broken, but means you can launch apps without thinking twice about whether you left it running on another machine.

Any thoughts are welcome. This could be a really useful script if the holes were patched up. In the meantime, if you’re a responsible multi-machiner who always quits their apps before switching Macs, check out DropboxAppSync.