xdg-open incorrectly opens file by protocol instead of type
$ xdg-mime query default image/webp 16:10
gimp.desktop
$ xdg-open https://cdn.discordapp.com/avatars/783920747482447893/4df0a23b20fb11cf807f5a3ffc1eca26.webp
Previously, it would correctly open the file in gimp
. Now it doesn't do anything at all tries to open in Firefox instead.
After looking into it more, it appears to be caused by commit d11b33ec
Rolling back the changes made to scripts/xdg-settings.in
fixes the issue.
Links to webpages correctly open in Firefox, and all other files correctly open in their associated program.
I've run into the problem again with this build too, I'm not sure why the problem went away momentarily
I managed to get back the expected behavior, and I wrote out as much information as I could about how I fixed my problem. After figuring all this out, this might be intended behavior. But it's definitely a painful process to get a seemingly basic behavior that I would expect to be the default.
--
-- Transcription from Discord:
I finally fixed it. I'm guessing a series of system changes lead to this. I'm assuming I'm in a niche group of people or something, since so many things got in the way of this functionality. I've tried so many things, and they've all kinda blurred together. So here's my best guess at the problem:
-
desktop
files can declare their own mimetype, and Firefox claims the entirety ofhttp
andhttps
by default -
xdg-utils
has special cases for http and https, and one of these special cases includes referencingtext/html
as a fallback.
The fallback to text/html
made it so xdg-settings get default-web-browser
returned a text editor after removing Firefox's mimetypes entirely.
Somehow all of these issues get circumvented if you
- Let Firefox claim the entirety of the
http
andhttps
protocol - Then negate this claim in your
mimeapps.list
with the "Removed Associations" section Looking something like this:
[Removed Associations]
x-scheme-handler/https=firefox-developer-edition.desktop;
x-scheme-handler/http=firefox-developer-edition.desktop;
Now the output of xdg-settings get default-web-browser
is still Firefox, due to the mimetypes declared in its desktop
file
But opening files that aren't webpages webp
, png
, mov
, etc. will open in their associated program
It's also worth noting that KDE Plasma's BrowserApplication
setting will also claim the entirety of http
and https
, even overwriting the negated claims in the mimeapps.list
-- End of Transcription