Getting Linux and OS X to play nice together: OmniFocus


Nowadays I primarily use OS X and rely on several commercial tools there to work effectively, specifically, 1Password, TextExpander, OmniFocus and PHPStorm. I still like to play with Linux from time to time though and being able to use it effectively is being able to access their data in similar tools there, where they are not available natively, such as PHPStorm.

Here's how I created a working solution for me with an xmonad based desktop (since I don't want to waste my life looking at Gnome & KDE apps), starting with the most difficult one, OmniFocus.

Interacting with OmniFocus

The bad news up front: Unless you are willing to invest significant time into reverse-engineering a full client, true read/write access is not possible. My goal was to be able to add items and read items in some form or another and that is possible.

Collecting actions

Collecting actions is actually fairly easy, just set up a Mail Drop adress and send yourself an email. A trivial script such as the following one makes it easy to send actions from the command line. 

echo -n "Your task: "
read title
echo -n "Optional description: "
read desc
echo $desc | mutt -s "$title" 
echo "Task created"

You also have the option of extending the syntax of that mail, if you install an AppleScript extensions.

Accessing your existing data

Getting access to your OmniFocus database isn't as easy, but it isn't that difficult either. Generally, the data sits in an sqlite database on the client. So the first step is to have access to that data.

I use a LaunchAgent to periodically copy that database to a personal server. From there I can easily run a cron task such as the one below to fetch the database on Linux. I recommend always only working on a copy which isn't written to by any client, to avoid conflicts.

*/10 * * * * rsync -u remote-server:~/OmniFocusDatabase2 ~

Now you have the database, so just write some SQL when you want to know what's due. However, you also have option of using the PHP-based tool OFReader I wrote, which gives you access to the most common queries, such as outputting tasks due:

screenshot of OFReader

See the Github page for all the details on installing it.