Bottom Line: I’m making progress on a small package that helps add tasks to OmniFocus from Linux (or CLI on Mac).

This post will be a work in progress as I make changes to the script.

Update 20140929: Released v0.25 to PyPI, major update. High points:

  • Now seems to be installing properly with pip3 install ofpy on both OSX and Arch Linux (haven’t tested with other distress yet).
  • Now python2 compatible.
  • Should create an example ~/.ofpy_config  file on first run for you to customize.

 

Introduction

As of Sep 10, 2014, I’m releasing the first very alpha version of a little script to help add tasks to OmniFocus from Linux. Inspired by the fact that I carry around my little Arch Linux Chromebook more than my trusty old 2009 Macbook Pro these days… but I still use OmniFocus as my primary task manager.

The goal is to have a command line interface that I can use to quickly jot down tasks, and those tasks will eventually end up in OmniFocus. Currently, this happens in a few ways:

  • If an active internet connection is detected, simple one-liner tasks are sent via OmniGroup’s MailDrop service, e.g. $ ofpy "Do something important."
    • Watch the quoting — it’s not necessary, but while $ ofpy this and that will work fine, $ ofpy don't forget the other will screw things up due to the single quote.
    • I also expect issues with quoting other special characters like $; I’ll have to figure out some kind of workaround.
  • If an active internet connection is not detected, simple one-liner tasks are written to a text file in a configurable directory. The file name is a timestamp in YYYYMMDDTHHSS format.
  • Whether or not an active connection is detected, more complex or longer tasks can be created in a text editor (defaults to vim, so far only tested in vim), in which case the first line will become the task name and subsequent lines will become the task note.

With regards to the files created in an editor, while I may eventually write some kind of daemon or cron job to check this folder every few minutes and try to re-mail things, I think I will at least initially settle for using a Dropbox folder and either Hazel or an AppleScript folder action to import the file to OmniFocus for OSX once it’s synced over by Dropbox. I realize this won’t work for folks that don’t have OF for Mac. One big reason I plan to go this route is that MailDrop currently doesn’t support any way to specify contexts, projects, due dates, etc. In contrast, I could come up with some plaintext (or perhaps JSON) format that would allow specifying these details, then use AppleScript to assign the values appropriately on the Mac. Or perhaps I’ll put a setting to allow the user to choose, if I can get both working.

Installation on Linux

You’ll need to have python3 installed for now (I may eventually backport to python2). No special libraries required.

Currently I have the basic functionality of the github version working on my Arch Chromebook. I also made it my first upload to PyPI… but it doesn’t look like the config file made it (not sure why), and I don’t know how to have pip do cool things like automatically install the executable. So for now I’m recommending installation from GitHub.

You should basically be able to:

  1. Clone or download the repo
  2. Move the directory to an appropriate location
  3. Copy the .ofpy_config file to your home directory and edit as appropriate
  4. Make ofpy.py executable with chmod u+x
  5. Symlink it to a reasonable place like /usr/local/bin

Basic commands to accomplish this are in the readme.

Installing the “client” portion on a Mac (optional)

Then, assuming you also have a Mac running Dropbox, OmniFocus and Hazel, you can install the second part:

  1. Create an ofpy folder in Dropbox, and open that folder in Hazel.
  2. Create a new rule that looks like this:
  3. Have the action run ofpy_hazel.applescript from the GitHub repo
    • You’ll need to open it in AppleScript Editor and re-save it as a binary .scpt file. These aren’t readable on the web and don’t transfer well computer to computer, which is why it’s currently in plaintext .applescript format.
  4. Make sure you have your .ofpy_config file set to put task files in the correct folder.

Limitations

  • As stated above, I haven’t yet implemented even an attempt at being able to assign contexts, projects, due dates, etc. For now, it’s all about just getting it into the inbox.
  • Even if I got that stuff implemented, it would only be through AppleScript and OmniFocus for Mac, adding more requirements.
  • I’m unlikely to get this to the point of supporting attachments.

Todo

  • File-based tasks
    • Make Hazel script (and AppleScript) for Dropbox sync to OmniFocus.
    • Make sure second line becomes note
    • Consider syntax for context, projects, due dates
      • Implement fuzzy matching?
  • General
    • Figure out how to install executable with pip
    • Programmatically create default config instead of copying
    • Resubmit version to PyPI