Hi All - I read through the existing URL Scheme topic and am still a bit confused as to whether I can open a note in Obsidian directly from outside Obsidian and if so, how to do this.
My goal is to have the URL scheme included in a Keyboard Maestro Macro so that whether or not Obsidian is open, the macro triggers Obsidian to open a specific note.
I’ve tried: Open the open URL action and open file action in Keyboard Maestro but can’t seem to get it to work.
When I try to open the URL with the action I get an action failed message in KM with "open URL failed with invalid URL:
When I try to open the URL as a file I get an action failed message about a non-existent path
This is what the URL scheme looks like when I copy and pate it:
I got the URL from the 3 dots in the same pane as the title of the note for “more options” and then selecting “copy Obsidian URL”
If I paste it in the web browser manually as you suggest and click enter, the browser asks if I want to open the page in Obsidian, which seems to work when I click enter - but when I put Open URL as an option in Keyboard Maestro I get an error message and when I put open a new tab in Safari with the URL pasted, it doesn’t open the URL unless I click enter manually.
The fact that web browsers have no trouble opening the URL seems to prove there’s nothing wrong with it. It must be something with the KM action, but I can’t help with that because I don’t use it. Sorry.
Maybe try looking at the KM docs and see if there’s some setting you’ve missed.
This is driving me mad. Pretty sure there is an issue with KM’s handling of special characters. This has been reported on their forum as well so hopefully we can get a solution soon.
This solution was horrible but I found a better way by launching the URL as a terminal command using the “Execute Shell Script” action in Keyboard Maestro:
Given the many type of Keyboard Maestro variables, it’s hard to say the exact sequence/pattern of % characters in the URI that will or won’t cause the error. As a result, sometimes an Obsidian URI will work with the Keyboard Maestro Open URL macro out-of-the-box (IOW: copy/paste) and sometimes you’ll see the orange error.
A simple way to continue using Open URL macro (or any other that will accept and process a URI), is by setting the Process setting (in the gear menu) to Process Nothing:
Thanks to @gglick, at the Keyboard Maestro Forum, for this.
FYI: The downside is, you will no longer be able to pass Keyboard Maestro variables into the url field of this specific action. Which limits more advanced Keyboard Maestro/Obsidian interaction.
Using the Execute Shell Script macro, mentioned above by @phy, should work. And you’ll pass in the Keyboard Maestro variable like this: $KMVAR_variable_name_here