Sunday, October 17, 2010

Running Things on Multiple Macs

I use Things as my core Trusted System in my personal GTD.  I wanted to use it on both my work computer and my personal machine.  At the time of writing, Culture Code is planning on providing Mac-to-Mac sync.  In the meantime, there's a reasonable workaround.

The basic idea is to put your Things database on a "Disk in the Cloud".  You can use any such service.  While I am using iDisk (comes with MobileMe), I'm current transitioning off that onto Dropbox.  I found incomplete instructions online (including Culture Code's FAQ).  Here's a step-by-step walkthrough.

WARNING: According to Culture Code's FAQ on this matter, you should NOT share a Things database where one machine is running Tiger (10.4) and another is running Leopard (10.5) or better.

WARNING: Make sure you take a backup of your Things database (at the very least, run a Time Machine backup) before you begin.

WARNING: Cultured Code does NOT support you running both instances of Things at the same time. Follow my instructions precisely and you'll not have a problem. Be aware, though, that it's not clear what damage might be caused if you open the Things database from both computers.


Step 1: Install Things on Both Computers

If you're like me, you already have Things installed on one computer.  You'll just have to install it on the second computer.  Cultured Code proudly offers a no-nonsense license allowing you to run the application on multiple computers by the same person.

On your second computer:

  1. Download Things from Cultured Code: http://culturedcode.com/things/

    It downloads as a ZIP file which your Mac will automatically unzip; the file that ultimately lands is Things.app.


  2. Copy Things.app to your /Applications folder.

    Just like you would to install any Mac application.

  3. Run Things.app to initialize it.

    You're allowing this second installation of Things to create all the folders and empty database.

  4. Add your License to this installation!

    It is important that you initialize this copy of Things with your license info. That data will NOT be synced across machines. To add your license, in the "Things" pull-down menu, select "License..." and enter your license information.

  5. Quit Things

    You're about to move the database for Things; best to quit the application before you do.

Step 2: Move the Things Database to a Shared Drive

Now, we'll make the database from our primary Things installation become our shared database by moving it onto the shared drive.  (My instructions assume you're using Dropbox, but again, it doesn't matter; just adjust your paths to point to the right location for your setup).

On your first computer:

  1. Make sure Things is NOT running.


  2. Create a folder on your shared drive to be the new home for your shared Things database.

    I'll just follow the directory structure we see for where apps store their per-user configuration in my set-up.  You can place this folder anywhere you want.  It must be on your shared drive.

    For iDisk users, the base directory is 


    /Volumes/iDisk

    and for Dropbox users, by default your Dropbox folder is located at:

    ~/Dropbox

    creating the directory that will be the home of your Things database:

    $ mkdir "~/Dropbox/Library/Application Support/Cultured Code/" (don't forget the quotes)

  3. Now, move your Things Database to this new location:


    $ mv "~/Library/Application Support/Cultured Code/Things" \
    "~/Dropbox/Library/Application Support/Cultured Code/"
    (quotes are required!)

  4. Now, we'll create a soft link from to where Things thinks the database to where you've just moved it:

    $ cd "~/Library/Application Support/Cultured Code/"
    $ ln -s "~/Dropbox/Library/Application Support/Cultured Code/Things" Things

  5. Let's make sure we're doing good so far. Launch Things on the first computer to make sure all is still well (you can launch it however you normally do, I'll show you a command-line way).

    $ open -a Things

    If your Things launched normally and you can still see all your data, you're good so far. If not, stop here and restore from a backup (and consider not doing this).

  6. Quit Things.

On your Second Computer


I'm assuming that by now your Shared Disk service has sync'ed the Things files to the second computer. This generally is pretty quick. Dropbox uses Growl alerts (the bubble-like notifications in the top right corner) to let you know of changes to your shared folder. Just make sure that you've got a green check mark on your Dropbox icon in the status bar. Once your shared folder is synced, you're ready to use it on the second computer.

  1. Make sure Things is NOT running.

    If you're running Things while you modify the location of the database, you risk corrupting the database.

  2. Delete the empty Things database.


    $ rm -r "~/Library/Application Support/Cultured Code/Things"

  3. Link the Things database from the shared drive:


    $ cd "~/Library/Application Support/Cultured Code/"
    $ ln -s "~/Dropbox/Library/Application Support/Cultured Code/Things" Things

    Now, you have both computers soft-linking to the shared folder.

  4. Fire-up Things, here, to ensure that you're now able to read the shared database on this computer as well.

    If you see all your data, you've done it. There's one more step, but grats, the sharing has started.
  5. Quit Things.

Write a Script to Launch Things from a Lock File


Technically, you could stop here. But doing so leaves you vulnerable to having Things running on both computers at the same time (which will undoubtedly, eventually, cause you to lose data if not corrupt the Things database). I'm going to provide you with a script, that when run ensures that Things isn't running on another computer, first.

On the First Computer


  1. Create the script "Things.sh" on the Shared Drive.

    In your favorite text editor create the file named "Things.sh" and save it to the Shared Drive (since everyone has TextEdit, I'm including instructions using that editor; any will do).

    $ cd "~/Dropbox/Library/Application Support/Cultured Code/"
    $ touch Things.sh
    $ open -a TextEdit Things.sh

    In this script include the following (I recommend you copy and paste instead of keying this all in yourself):

    #/bin/bash
    
    
    acquire_lock() {
      DID_ACQUIRE_LOCK=1
      MY_KEY=`hostname`
      if [ -f "$LOCK_FILE" ]; then
        CURRENT_KEY=`cat "$LOCK_FILE"`
    
        # If I possess the key, this is my lock file (perhaps Things terminated abnormally?)
        if [ "$MY_KEY" == "$CURRENT_KEY" ]; then
          DID_ACQUIRE_LOCK=0
        fi
      else
        echo $MY_KEY >"$LOCK_FILE"
        DID_ACQUIRE_LOCK=0
      fi 
    
      return $DID_ACQUIRE_LOCK
    }
    
    release_lock() {
      if [ -f "$LOCK_FILE" ]; then
        rm "$LOCK_FILE"
      fi
    }
    
    report_already_locked() {
      # prefer using Growl (installed with Dropbox)
      if [ -f /opt/local/bin/growlnotify ]; then
        growlnotify -s -a Things.app -t "Can not start (lock file exists)" \
                    -m "Things is already running on another computer.  Quit Things on that computer, first. \
    Or, if you know what you are doing, delete the lock file at: \
    $LOCK_FILE"
      else
        # Otherwise, use the built-in text-to-speech
          say -v Alex "Things is already running on another computer.  Quit Things on that computer, first."
      fi
    }
    
    # Customize this path to match a path on the shared drive:
    LOCK_DIR="$HOME/Dropbox/Library/Application Support/Cultured Code"
    LOCK_FILE="$LOCK_DIR/Things.lock"
    
    # Here's where all the action starts...
    if (acquire_lock); then
      open -a Things -W
      release_lock
    else
      report_already_locked
    fi
    
  2. Save the file.
  3. Set the script to be "executable" on both computers.

    On BOTH computers run this command:


    $ chmod +x "~/Dropbox/Library/Application Support/Cultured Code/Things.sh"


  4. Launch Things from the shell script.

    Now, every time you want to start-up Things, fire-up this script.

No comments:

Post a Comment