Run a shell script when opening a file in Obsidian (w/Keyboard Maestro on MacOS)

This is an… overcomplicated solution. But it works!

I want a python script to run whenever I open file A in Obsidian. This script fetches some information from the web, formats it in a way that I like, and writes it to file B (which is embedded in file A)

My solution was to create a Keyboard Maestro action that is triggered by a URL on the KM built-in web server. I include that URL as the src in an img tag in file A.

With me so far?

Then, I use obsidian-force-view-mode-of-note plugin to force the note to render in preview when file A is opened. The img tag requests the “image,” the script is run, and file B is written.

Fragile? Yup. Working tonight and bringing me joy? Definitely.