I don’t like all of that stuff, so I took a note from SirCmpwn and replaced xdg-open in my $PATH with my own script:
I used OpenBSD as my desktop for a few years in college, and had shell scripts for everything… …I can’t believe I never thought to do that rather than just giving in and configuring everything as described in the above post.
I am using this Python script to be able to choose the application instead of using the default one: https://github.com/vincentbernat/i3wm-configuration/blob/master/bin/xdg-app-chooser.
However, knowing how xdg-open works is still useful as many applications will not call xdg-open but rely on a library (like Gio) to do the same work.
I did the same, got tired of the scripts and wrote my own replacement that is configured with a JSON file. Xdg-open is so very complex, it’s always very hard to predict what is going to launch.
The census among everyone I discuss this with is that xdg-open is too complicated for power-users to bother to understand. If this is the default tool for opening URIs then its a clear indication to me that the “Linux desktop” is in a death spiral.
I mean, if xdg-tools being a hot dumpster fire is an indication of a death spiral, it’s a heck of a long one – they’ve been pretty much the de facto standard for more than ten years now.
At some point, around 2012 or so, I actually did the unthinkable and spent a few days learning how to use them. It’s unthinkable because the documentation is so bad (and incomplete) it’s not even funny. And I gave up on them because the whole thing was so brittle, and so prone to sudden breakage of all sorts, that it was pretty much useless. Not all is xdg’s fault – some of the more absurd failures (like having all MIME file types associated with Wine’s explorer.exe, or better yet, Firefox, which unsurprisingly opens anything you throw at it and dutifully prompts you what application you want it opened with, and the default choice is, yep, Firefox) are probably packaging problems. But the end result is so horrifyingly bad that I suspect it’s single-handedly responsible for the fact that so many people just open files from their terminals or with weird 1980s-like contraptions like nnn.
I really did not liked how xdg-open changed all my preferences all of a sudden randomly so I came up with my own see.sh replacement - https://vermaden.wordpress.com/2021/04/22/freebsd-desktop-part-24-configuration-universal-file-opener/ - described here.
Oh the default application quest.