Can't figure url note links from linux terminal

Things I have tried

I put a desktop file in /home/david/.local/share/applications/

(called “obsidian.desktop”)

with this:
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Exec=obsidian %u
Icon=/home/david/SyncthingFolders/allScripts/todoFiles/icons/obsidian.png
Name=Obsidian
StartupWMClass=obsidian
X-AppImage-Version=0.8.15
Comment=Obsidian
Categories=Office;
MimeType=text/html;x-scheme-handler/obsidian;

and here’s the terminal output:

[email protected]:~$ obsidian obsidian://open?vault=zettlrMarkor&file=recentNotes
[1] 30407
[email protected]:~$ 2021-08-05 03:25:12 Loading main app package /snap/obsidian/x1/resources/obsidian.asar
Gtk-Message: 21:25:12.721: Failed to load module "appmenu-gtk-module"

(obsidian:30407): Gtk-WARNING **: 21:25:12.739: Theme parsing error: gtk.css:1555:23: 'font-feature-settings' is not a valid property name

(obsidian:30407): Gtk-WARNING **: 21:25:12.744: Theme parsing error: gtk.css:3593:25: 'font-feature-settings' is not a valid property name

(obsidian:30407): Gtk-WARNING **: 21:25:12.745: Theme parsing error: gtk.css:4055:23: 'font-feature-settings' is not a valid property name
2021-08-05 03:25:12 Checking for update using Github

What I’m trying to do

I want to be able to open a specific note within obsidian from outside obsidian, like from a terminal or a bash script.

The link I used was correct because it was generated by dragging the link to the existing file into an external text editor. I also tried adding “.md” to the end.

What happens:

obsidian launches, but opens the most recently viewed file, not the “recentNotes” file.

What am I doing wrong?
version: 0.12.12 (snap)
linux version: Ubuntu 20.04.2 LTS

I use Obsidian 0.12.12 (installer 0.12.10) as an AppImage on Linux Mint 20.2 (based on Ubuntu), and I have

~/.local/share/applications/Obsidian.desktop:

[Desktop Entry]
Name=Obsidian
Comment=Markdown Notetaking App
Terminal=false
GenericName=Text Editor
Type=Application
Exec=/home/matthias/AppImages/Obsidian-0.12.10.AppImage %u
Icon=obsidian
StartupWMClass=obsidian
MimeType=x-scheme-handler/obsidian;

(You probably shouldn’t set Obsidian as a text/html handler.)

and I call up Obidian from the terminal using xdg-open:

[email protected]:~$ xdg-open obsidian://open?vault=Knowledgebase&file=Discord
[1] 42953
[email protected]:~$ 2021-08-05 15:37:30 Loading updated app package /home/matthias/.config/obsidian/obsidian-0.12.12.asar
Received callback URL obsidian://open?vault=Knowledgebase
2021-08-05 15:37:31 Checking for update using Github
2021-08-05 15:37:31 Success.
2021-08-05 15:37:31 Latest version is 0.12.12
2021-08-05 15:37:31 App is up to date.

[1]+  Fertig                  xdg-open obsidian://open?vault=Knowledgebase

Doesn’t work. Why? Because the obsidian URI isn’t quoted and the & will send the first part of the string to the background!

Using:

[email protected]:~$ xdg-open "obsidian://open?vault=Knowledgebase&file=Discord"
[email protected]:~$ 2021-08-05 15:59:14 Loading updated app package /home/matthias/.config/obsidian/obsidian-0.12.12.asar
Received callback URL obsidian://open?vault=Knowledgebase&file=Discord
2021-08-05 15:59:15 Checking for update using Github
2021-08-05 15:59:15 Success.
2021-08-05 15:59:15 Latest version is 0.12.12
2021-08-05 15:59:15 App is up to date.

works fine! (Check on the “Received callback” line: it now got the full URI, including the file name.)

Have you ran the following?

xdg-mime default obsidian.destkop x-scheme-handler/obsidian
update-desktop-database

The output of both xdg-mime query default x-scheme-handler/obsidian and xdg-settings get default-url-scheme-handler obsidian should be obsidian.desktop.

Also double-check that Obsidian appears in ~/.config/mimeapps.list:

[Default Applications]
...
x-scheme-handler/obsidian=obsidian.desktop

Thanks to both of you :slight_smile:

I’ll try those things and post back (hopefully within a day or so)

@Moonbase59 : It works!!! Thank you so much!

(should have known to try using quotation marks, ha ha)

1 Like

Hee hee! Don’t we all fall into these kind of traps, once in a while?

Glad it works for you!

(and you’d probably like to repair your theme, or file a bug hint. hint)

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