Obsidian freezes entirely when an attachment is open with an external program

Hello,

I gave one last attempt at fixing this on my own as it seems this is not a priority for the devs and I found an actual workaround. Make an alias in your ~/.bashrc, ~/.zshrc, etc, with the following:

alias obsidian="XDG_CURRENT_DESKTOP=GNOME obsidian"

Reload your shell, and you’re good to go. Obsidian will open files with external apps without freezing.

Explanation:

If you’re using a WM, then XDG_CURRENT_DESKTOP is not set. If that’s the case, then electron falls back to xdg-open to open files. That should be fine, but for unknown reasons, in obsidian, it is done in a blocking way, meaning that while the external application is running, obsidian is frozen. Other electron apps doing similar things are not blocking so this is really an obsidian issue I think.

If you are using a DE, them XDG_CURRENT_DESKTOP is set to a known standard DE. For instance if you use Gnome then the value set is GNOME, when this is the case, electron will make use of the DE’s preferred file opener, which is not xdg-open but could be anything that relies on gio a low-level utility and library in the GLib world for dealing with I/O, networking, IPC, Gnome/GTK settings, etc. Somehow this works nicely with obsidian as nobody ever encountered this issue while using Gnome. The same reasoning also exist for KDE but I don’t know anything about this DE.

Solution: if you use a WM and manually set XDG_CURRENT_DESKTOP to GNOME that means that when you launch obsidian with such an environment variable set, electron will think you run Gnome. On my system it means that gio is called directly instead of xdg-open or any other file opener. Of course you need to have gio installed (on Debian, it’s in libglib2.0-bin, and could be you already have it as it is often a dependency of large GTK/GLib stuff, even if you don’t use Gnome). For sure in theory xdg-open is the proper method (as in freedesktop standards) to deal with the issue, and hopefully this will eventually be properly fixed in obsidian. In the meantime this workaround is the only elegant and least intrusive way I could figure out to make obsidian working properly with a WM.

HTH!