Opening Obsidian URL Scheme from outside Obsidian?

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:

obsidian://open?vault=Music%20Ed%20-%20Obsidian%20Vault&file=0.01-Class%20Qual%20Research%20MOC

Any suggestions of how I can open the URL scheme as part of a Keyboard Maestro macro?

Thank you!

1 Like
  1. Where did you get that URL? From the obsidian menu?
  2. Have you tried pasting it in the web browser and opening it from there?

Sorry about the delayed response

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.

1 Like

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.

1 Like

Lofi workaround would be this:

image

Assuming ⌘O is set to Obsidian’s Open quick switcher this will activate Obsidian, open Quick switcher, paste the title of your note, and open it.

Won’t be as fast as calling a note directly.

1 Like

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:

Replace just OBSIDIAN NOTE URL with your note’s url. E.g.: open "obsidian://open?vault=_Notes&file=%E2%80%BA%20Init"

2 Likes

Hi,

This was discussed on the Keyboard Maestro forum here:

The issue has to do with the % character used in the Obsidian URI (which is standard for URIs).

% is a reserved character in Keyboard Maestro. It uses a few combinations of multiple % get variables for its macros:

https://wiki.keyboardmaestro.com/manual/Variables?s[]=variable#Using_Variables

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 :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

https://wiki.keyboardmaestro.com/action/Execute_a_Shell_Script#Using_Keyboard_Maestro_Variables

But I haven’t tested that.


I know this thread is old, but hopefully it helps.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.