I had problems with the ‘Open in default app’ feature under linux. I am running Arch with no pre-built desktop environment, so I am used to this kind of stuff not working out of the box. After a little bit of digging I found a rather hacky solution which I doesn’t quite satisfy my needs. Therefore I wanted to share my solution and ask for other peoples solution.
Long story short: When I opened, say, a PDF, my reader okular would open just fine but Obsidian would become unresponsive until I closed the okular again. Annoying but at least I could open it.
Way more annoying was the fact that I could not open the markdown files with my default editor neovim. When I tried to do that, Obsidian just became unresponsive and I had to close it.
Most Linux systems rely on XDG-MIME to handle their file types and default applications. So do I. To open a file with the configured default application you would simply run
xdg-open /path/to/file.type. I suspected that Obsidian does the same and I so found nothing to contradict this assumption. This method however by default simply spawns the application, which in turn blocks the spawning process. In this case obsidian. In a terminal this can be handled in different ways. I know of two ways: One is
xdg-open /path/to/file.type $, spawning the process as a background process which is still coupled to the spawning process (i.e. when the spawning process closes the child process closes as well) but doesn’t block it anymore. The other way is to run
xdg-open /path/to/file.type $ disown which causes the child process to completely detach from the spawning process. It is a mystery to me why Obsidian doesn’t run the default apps in one of those ways and I am not aware of a way to bring it to do this in any way other than with my hacky solution. It could well be that I have overlooked something and there is either a way to do this with either Obsidian or XDG itself without such annoying hackery. But I seem to not be the only person with this problem as I found this forum post which also mostly already provided the hacky solution.
To have Obsidian properly open the application and still be use-able one has to create a new
.desktop-file for xdg and a script that is called which does the ‘disowning’ for Obsidian. The solution for a PDF reader is already given in the forum post. For neovim I had to do one extra modification because it is not a visual program and therefore needed to be spawned in my terminal emulator
alacritty. Just for completeness’ sake and for anyone that might know a little less about Linux I will quickly give my solution for that.
- Create the wrapper script in
/usr/bin/nvim-wrap(ensure it’s executable
chmod +x nvim-wrap)
#!/bin/bash alacritty -e nvim "$1" & disown
- Create the desktop file (I simply copied the existing
~/.local/share/applications/nvim-wrap.desktopand modified it to have the endresult:
[Desktop Entry] Name=Neovim Wrapper TryExec=/usr/bin/nvim-wrap %F Exec=/usr/bin/nvim-wrap %F Terminal=true Type=Application Icon=nvim Categories=Utility;TextEditor; StartupNotify=false
So, this works. But I would have to do it for every application I would like to start from within Obsidian and in the meantime alter the behaviour of the rest of my system which hasn’t been a problem for me yet but could be undesireable. As I see it, Obsidian should take care of spawning the process as a background process or even disown it. If anyone knows of a reason why this is done this way by Obsidian or how to more cleanly fix the problem I would be delighted to hear from you.