Tech help beeminding OmniFocus

I’ve just started trying to Beemind my own OmniFocus usage and I think I’ve got a good basic approach sorted out:

  • Use Hazel to trigger sending datapoints when OmniFocus syncs.
  • Use JavaScript for Applications (JXA) to avoid the monstrosity of AppleScript.
  • Use Node and the osa2 module to wrap JXA calls with a more general programming environment.

So far, the only thing I’ve got automated is my inbox count, but I also intend to add some support to beemind-arbitrary-things (i.e. did I check off a task containing the words “gratitude journal”). You can see the work-in-progress at dehowell/beeminding-omnifocus.

This is the Hazel rule I’m using to trigger the script:

That rule runs in the folder ~/Library/Containers/com.omnigroup.OmniFocus3/Data/Library/Application Support. Note that I am using the OmniFocus 3 beta, so YMMV if you are using OmniFocus 2. Either way, you’ll need the Pro version for AppleScript support.

JXA can do almost everything AppleScript can do, but with JavaScript. Some things still look magical and weird, but getting the inbox count is at least straightforward:

Application("OmniFocus").defaultDocument.inboxTasks().length
3 Likes

I renamed the repo to omniminder and it is now much more likely to be usable by someone else, if anyone wants to give it a whirl. As of right now, it supports:

  • Beeminding size of OmniFocus inbox
  • Beeminding number of projects that are due for a review
  • Beeminding arbitrary daily tasks that match a pattern (somewhat like how Complice supports beeminding arbitrary things)
2 Likes

WARNING! I have a goal for tracking this and it is turned out to be vulnerable to spurious derails. OmniFocus projects become “due for review” at midnight, no matter what time of day they were last reviewed. So I’ve a had a couple of instances now where a critical mass of projects all went due for review at the same time at midnight, just in time for my goal to derail (but not in time for me to get get any notification that it’s going to happen!)

If you end up doing something similar, I highly suggest setting your goal deadline to sometime in the middle of the day, so that you have some lead time to deal with pending reviews.

1 Like

Or perhaps even just at 23:59. I have many of my goals set to that simply because my brain isn’t very good at recognising the difference between 12:00 AM and 12:00 PM…

2 Likes

I wonder if you can help, I am having difficulty implementing Omniminder to Beeminder my Omnifocus tasks.

I am currently running Omnifocus using 3.11.1 (v149.5.0) on macOS BigSur v11.0.1 and have created a folder called .omnifocus under $HOME. I added my auth_code to $HOME/.omniminder/config.json and installed nvm and node using Homebrew.

I have also set up a ‘Do More’ goal in Beeminder called ‘gratitude’ and then created the $HOME/.logs folder. Next, I created a Hazel rule against the Omnifocus folder containing the lock file ‘OmniFocus.ofocus-lock’. The apple script for when the script is run contains the following:

export NVM_DIR="$HOME/.nvm"
. "/usr/local/opt/nvm/nvm.sh"

omniminder >> /Users/*****/.logs/omniminder.log 2>&1

I then created a project in Omnifocus project called ‘Routines’ to match what is written in the config.json file containing the following tasks:

  • ‘Write in gratitude journal’
  • ‘Write in gratitude journal 1’
  • ‘Write in gratitude journal 2’
  • ‘Write in gratitude journal 3’

Three of these tasks were completed and then synced in Omnifocus. However, Omniminder command did not update the goal in Beeminder as I expected. I’m not sure what I am doing wrong. I appreciate any help you can provide.

Many thanks

Was there anything in the log file /Users/*****/.logs/omniminder.log here? Also, I don’t think my instructions said this explicitly, but you will probably have to create the .logs directory.

Honestly, I haven’t personally been using omniminder for awhile. Running the omniminder command in the terminal still works fine on my machine, but I am not on Big Sur yet. I’d recommend trying to narrow down whether the problem is with the omniminder command itself or in the Hazel rule.

Running the script when the file OmniFocus.ofocus updates is a bit of a hack, for example, and the Omni Group might have moved the file or changed how they track changes for syncing. If that happened, your Hazel rule may just not be triggering.

1 Like

@dehowell
Thank you for your response. The issue is related to running omniminder rather than Hazel as I tried to get it to work before implementing the Hazel rule. I included the Hazel rule in my post for completeness.

I previously created the .log directory under $HOME and there was a /Users/*****/.logs/omniminder.log file. A portion of the log file indicates that it cannot find the ‘beeminder’ module:

node:internal/modules/cjs/loader:928
  throw err;
  ^

Error: Cannot find module 'beeminder'
…

Although I am not sure why? Any ideas?

Oh, that sounds like a problem with JavaScript resolving the dependencies when Hazel runs. In the screenshot of my Hazel rule up above, you’ll see that I’m explicitly setting the NVM path, running the NVM setup script, and providing the precise path the to the omniminder executable. That’s all for the sake of making sure Node is initialized properly to find the libraries the script depends on.

Those sorts of things are going to be particular to how you’ve installed Node on your system, so I can’t really tell you what the right configuration is for you. But I hope that gets you in the right direction, and good luck!

Thanks for the pointers. I have reinstalled nvm and node, so it looks like I am a little closer to getting this to work. However, can you clarify where to store the downloaded omniminder files. If I’m reading this correctly, the explicit path in your Hazel script looks like it being explicitly called and stored in the /Users/dave/.nvm/versions/node/v8.9.4/bin/ folder. Should the folder omniminder folder or omniminder.js be stored in the /bin folder.

I clone the omniminder git repository in my home folder, alongside the rest of my git repos. The omniminder command ends up in the node v8.9.4 directory by virtue of running npm install -g from within the omniminder repo — that’s NPM shorthand for “install globally”. On my
system, the file /Users/dave/.nvm/versions/node/v8.9.4/bin/omniminder is a copy of $HOME/src/omniminder/omniminder.js that NPM made when I ran npm install -g. There’s nothing special in the omniminder repo to do the copying, it’s just standard NPM functionality, driven by having a scripts defined under the “bin” key in package.json.