Adding Applescript to OF 2 Tool Bar

I'm fortunate enough to be able to use a Mac with my day job. However I've recently run into problems of creating, or updating, a script or automation method on one Mac, only to find it missing on the other. The tipping point was when I couldn't produce a list of open tasks for a project at work because a recent update to an Applescript I made was only on my Mac at home.2 I got home that night and knew I needed to work out a way to update all my Applescripts related to OmniFocus and keep them organized for both home and work.

OmniFocus 2 Database

When I started going through the Applescripts I had saved for OmniFocus I noticed some of them weren't working. Quite a few of the scripts I have are based on the original scripts Rob Trew (@ComplexPoint) created for OmniFocus 1. Changes to OmniFocus and OS X 3 has led Omni Group to change where the OmniFocus database is located. This caused most of Rob's original scripts to break. So I started going through the scripts I had and updated them up for OmniFocus 2.

The first thing I needed to do was make sure all my scripts knew the correct path to the OmniFocus database. In older OmniFocus scripts, the database location would be listed at ~/Library/Caches/com.omnigroup.OmniFocus. The correct location in OmniFocus 2 is ~/Library/Containers/com.omnigroup.OmniFocus2/Data/Library/Caches/com.omnigroup.OmniFocus2.

With this update, most of the scripts would automagically 4 work again.

Set OmniFocus Scripts Folder

The next thing I wanted to do was get some of the common Applescripts I use on to the OmniFocus tool bar. Out of the box, OmniFocus has a default scripts folder, ~/Library/Scripts/Applications/OmniFocus that you can see from the OS X menu bar:

However this is Apple's default folder location for scripts, not the one OmniFocus wants to use. 1 So if you add scripts to the default folder, you cannot add them to the OmniFocus tool bar.

To locate the real OmniFocus script folder, open OmniFocus and go to the Help menu and click on the Open Scripts Folder. This is the script folder that can be accessed by OmniFocus and used to add scripts to the OmniFocus tool bar.

So now both folders had the most recent revisions of my OmniFocus Applescripts.

Keeping them all in sync

Now that I've updated some of the scripts and figured out all the proper folders, I needed a way to keep the folders in sync with each other. Using Dropbox and Hazel I created a simple process to keep the files synced in all three folders:

  1. Dropbox Master Folder: First I created a master folder on Dropbox that will hold the updated OmniFocus scripts I want to have available to me. This is where all new or updated files will be saved.

  2. Create a syncing rule: In Hazel, I created a rule to sync the two OmniFocus script folders with the scripts from the master Dropbox folder.

With the Hazel rule in place, all three folders are sync'd with the most recent version of the Applescript.

Now all I have to do is repeat the Hazel rule on my Mac at work and all of the Applescripts will be updated to the correct folders too. Any updates I make to the master set of Applescripts, from either my home or work Mac, will now update all the OmniFocus script folders on both computers.

Wrapping it all up

With the Applescripts being the proper OmniFocus folder, I can add them to the toolbar and run them directly from OmniFocus.

The two icons I have shown above do the following:

  • Task_Due_List: This script pulls all my tasks +/-7d from today and outputs them to a Markdown file.
  • Open_Item_Count: A statistical look at the number of open action items I have in OmniFocus.

  1. Not sure why Apple creates this folder, because OmniFocus can't control it due to sandboxing. 

  2. Back to Mac is not an option at work due to the network setup. Setting up a VPN is now on my to do list. 

  3. Due to sandboxing. 

  4. Which is always the best thing that can happen when you mess with someone else's scripts.