Script Away Your Annoyances – Glueing Evernote and Omnifocus via JavaScript

OmniFocus has become my personal task tracking tool du jour, and I’ve come to rely on it for a morning reminder of my daily routines. One of those routines is to clear my Evernote inbox–things in that notebook need to be filed away for long-term storage while I can still remember why I put them in the inbox in the first place.

After a few weeks, I found the task of bringing Evernote to the foreground so I could check the inbox fairly annoying; I don’t want to bring it up if there’s nothing to process. So I wrote a JavaScript program to keep my OmniFocus task updated with the number of unprocessed items in my Evernote inbox.

I like my 'Process Evernote inbox' OmniFocus task to always tell me how big the inbox currently is.
I like my ‘Process Evernote inbox’ OmniFocus task to always tell me how big the inbox currently is. Image credit : me.


As you can see in the screenshot above, my OmniFocus ‘Process Evernote inbox’ task currently indicates that there are three unprocessed notes. This is the signal I need to bounce over there and archive them. If the number of unprocessed notes is zero, then I know I can check off that task and move along without switching over to Evernote.

A couple of years ago, I may have given up on automating this, or not even thought of it, because I was frightened of AppleScript. You see, Evernote and OmniFocus teams have done a good job of making their applications scriptable by programs, but AppleScript was something I didn’t want to touch. Have you ever seen it? Yecht. I’ll give it the benefit of the doubt and assume it had its time and place, but ugh, it’s not for me.

But last year, with the release of Yosemite, Apple added support for driving automation via JavaScript programs. Now, this I can do without learning an archaic language! I looked into it, and, sure enough, Evernote and OmniFocus export the right APIs for me to automate everything I need.

Here’s a link to my project. And the source, written in CoffeeScript, is here.

The program is automated via Rake tasks to automatically compile the program and generate a launchd configuration file. Type rake help for more information.


A couple of things did hang me up for a little while:

  • I didn’t realize I need to read properties by calling a function; instead, I was thinking it was more like a JavaScript property and I didn’t need the parens. Now that I realize that the functions are wrappers around getters and setters, it’s no big deal. And it was well documented. But it still took me a little while to internalize. Oh well.
  • I had to set up launchd to run my program every minute. I’m unaware of any API to make these programs event-driven; I did some searching and didn’t find anything. If I missed something, please let me know.

Future Improvements

I would like to update a few things:

  • It would be nice to send some more logging information to OS X’s
  • Now that I’m used to the Evernote task telling me how many things need to be processed, I’d like to update some other tasks, like the ‘Process email inbox’ task, to convey the same information.


OS X’s automation facilities are more accessible than ever now that we can access the APIs via JavaScript. One of the biggest upsides of my work here is that now the world of OS X automation is wide open to me.

Other posts in this series: