(Yes, I set up my .desktop file correctly with %u – at least, I think I did.)
Hi all,
I’m running Obsidian 1.6.7 on Ubuntu 24.04, and I’m trying to open a vault directly from command line. (Ultimately I want to create a system hotkey to open my daily note file and a separate one for my task dashboard file; right now I’m stuck at the phase of opening a vault with open obsidian://open?vault=myvaultname
from CLI so I’m simplifying to just that portion of it.)
If I understand the Obsidian URI page and this issue correctly, the way to do this is by doing open
from terminal (let’s say just opening the vault right now rather than a particular file):
open "obsidian://open?vault=myvaultname"
From what I understand, this is supposed to open the myvaultname
vault in Obsidian, but it’s not working and I’m running into errors. I think I worked my way around one error, but I’ll start at the beginning just in case my fix for the first error is the cause of the second.
The setup:
- When I installed I unpacked the AppImage using
Obsidian-1.6.7.AppImage --appimage-extract
and installed to/opt/Obsidian
. I actually did this originally to get around some SUID weirdness in Ubuntu 24.04 (see this AskUbuntu post) but setting up the URI stuff also seems to require this setup. - My
/usr/share/applications/obsidian.desktop
file looks like this. As far as I know this is correct; in particular my understanding is the%u
in theExec
line is necessary to pass the URI:
[Desktop Entry]
Name=Obsidian
Exec=/opt/Obsidian/AppRun %u
Terminal=false
Type=Application
Icon=/opt/Obsidian/obsidian.png
StartupWMClass=Obsidian
Comment=Private and flexible writing app
MimeType=x-scheme-handler/obsidian;
Categories=Office;
- I doubt it matters, but just in case it affects the desktop stuff, I’m using vanilla GNOME 46 and x (not wayland).
The problem:
- I am calling:
[ myusername@myhost:~ ]$ open obsidian://open?vault=myvaultname
- Expected behavior: Open Obsidian to myvaultname (or switch focus to Obsidian if it is already open).
- Actual behavior: Complicated, see below.
Using just this setup, running open
fails as the app doesn’t seem to be pointed to the correct executable:
[ myusername@myhost:~ ]$ open obsidian://open?vault=myvaultname
/opt/Obsidian/AppRun: line 49: /obsidian: No such file or directory
(Using quotes didn’t change anything. Also, my vault name has an underscore in it, so I tried replacing it with %5F in case that was related, but that didn’t change anything either.)
So I figured for some reason the AppRun file isn’t setting the directory correctly. So I hardcoded the directory by adding the following to /opt/Obsidian/AptRun
just after line 23 (after it’s done trying to set APPDIR by itself), so that the executable would correctly be /opt/Obsidian/obsidian
:
APPDIR=/opt/Obsidian
This… sort of worked, see below.
When running with that added hardcoded line (and Obsidian not already running), I get some strange behavior – it works, but it doesn’t seem to think that it works. First I get a popup saying the vault isn’t found. But then when I click “Ok” on the popup, the myvaultname vault loads correctly anyway (and some more info appears on the console).
In more detail, I enter:
[ myusername@myhost:~ ]$ open obsidian://open?vault=myvaultname
Then I get a popup saying
Error
Vault not found.
Unable to find a vault for the URL obsidian://open?vault=myvaultname
Ok
Then when I click Ok, the vault loads (correctly AFAICT) and the following gets written to terminal:
2024-09-02 17:42:50 Loading main app package /opt/Obsidian/resources/obsidian.asar
Received callback URL obsidian://open?vault=myvaultname
MESA-INTEL: warning: cannot initialize blitter engine
2024-09-02 17:42:55 Checking for update using Github
2024-09-02 17:42:55 Success.
2024-09-02 17:42:55 Latest version is 1.6.7
2024-09-02 17:42:55 App is up to date.
I also get control of the terminal back, though some additional messages also continued to write to the same console (this repeats 3 total times) – I think this is unrelated but am including it here just in case:
[36023:0902/134307.298352:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 1 times!
The behavior above is when Obsidian was not already open. When Obsidian was already open (to the myvaultname vault), it seems to just not do anything at all (it doesn’t focus Obsidian, and if I add a “&file=Test/File.md”, it does not open the file. The same popup appears; after dismissing it the console shows:
[ myusername@myhost:~ ]$ open "obsidian://open?vault=myvaultname&file=Test/File.md"
2024-09-02 17:51:05 Loading main app package /opt/Obsidian/resources/obsidian.asar
Received callback URL obsidian://open?vault=myvaultname&file=Test/File.md
2024-09-02 17:51:07 Checking for update using Github
Any tips for how to set up the URI callback correctly? (Or failing that, is there an easier way to open+focus Obsidian to a particular file from CLI?
Thanks!