Hello.
I’ve built a little server-app that I’m trying to integrate with OmniFocus. I’m looking for a way to run a sync-script periodically without stealing focus.
I have a small server app that accepts JSON tags from OmniFocus and pushes them to other services. Now I can tag things with “reclaim” and they just pushed into reclaim.ai and auto-scheduled in my calendar. I can tag things with “Asana” and they get pushed into asana, where other teammates get visibility. I have a Proof of Concept that works.
I’m triggering this process on OSX using launchd. Launchd can then trigger an applescript or JXA script, which “tells” Omnifocus to “eval” an OmniFocus automation script. I’ve also got it working with launchd running a shell script, which uses a Omnifocus app-specific URL (omnifocus:///[SCRIPT_HERE]) to run the Omnifocus automation script.
I’m keeping this “automation plumbing” very simple and lightweight. When the OmniAutomation script runs, it calls out to a web-server REST endpoint, gets retrieves a much larger, more involved script that collects tasks with certain tags, and then posts that data back to the server. The server then pushes it into various APIs of other services. I’m keeping the ‘main’ logic on the server because I can maintain it more easily there, and grow it in tandem with the syntonization logic of the other services I’m trying to integrate OmniFocus with.
The problem I’m having is that every-time the launchd fires the intermediary (via applescript, JXA, or shell), Omnifocus jumps into focus, stealing my focus from the user. This is pretty terrible if you are in the middle of typing something and all of a sudden your keystrokes are going into OmniFocus unexpectedly.
How can I trigger this behavior (getting instructions from a server, posting that data back to server, modifying data in OmniFocus based on the server’s instructions), without stealing focus from the user?
Is there a way to run Omnifocus Automation while keeping OmniFocus in the background? How?
Is OmniFocus Automation the wrong tool? Is there another way to read and write PmniFocus data reliably? What is it?
Alternatively, will Omnifocus sync server/Omnifocus-for-the-web ever have a REST or other always-on accessible endpoint? (I had tried reverse engineering the Omnifocus-for-the-web APIs, but it was too cumbersome.)