Mime; Can't find where default files are set by installing apps

OK, I have no idea if this is somehow specific to our minimal templates or not.

I have a qube (ultimately based on Debian-12-minimal) which has the “wrong” application set to be the default when I click on a PDF (it’s opening a scanning utility that’s supposed to create PDFs, not view them).

I have no idea how the system decides this. Allegedly, it’s mime, and according to this:

https://wiki.archlinux.org/title/XDG_MIME_Applications

which basically gets pointed to by every page I can find that deals with questions like this, I should be able to go to either /usr/local/share/applications/mimeapps.list or /usr/share/applications/mimeapps.list to see the defaults.

There’s no such file. At all.

So somehow, the system is setting a default here, but I can’t for the life of me figure out how.

The documentation simply leads me around in circles, AND OBTW the supposedly easy way to do this (update-alternatives–which has a very user belligerent interface) has NO notion what “viewing a PDF” is.

Does this file exist?

~/.local/share/applications/mimeapps.list

p.s.: It is strange that /usr/share/applications/mimeapps.list does not exist. Should be present. It is set to Evince on my Fedora XFCE templates.

And that doesn’t make it automatically a badly designed system, only one you don’t understand yet. I’ve edited the post title, please abstain from unnecessarly swearing directed at people in the future. (To be clear: please abstain from unnecessary swearing in general, but when directed at people it’s a no-no on this forum.)

Fair enough on the title. My apologies.

As far as my claims of its design, I can at the very least claim it’s poorly documented. I know the default is set somewhere, but cannot find out how.

And it seems to have changed often enough (and differs enough by distro) that the documentation is contradictory as far as it goes.

1 Like

Not only does that file not exist… ~/.local/share/applilcations (the directory) doesn’t exist. Nor would I expect it to…I’ve made no user mods as of the time I start the disposable; I haven’t even hunted through the menu for the app I want (which seems to create a user override).

This is why I am so frustrated by this. It’s being set SOMEWHERE. It must be. I’ve periodically tried to navigate through the mime files in the past when I can find something that will tell me where to look, and seem to find nothing but sequences of links that go around and around in circles.

None of the docs will explain what’s actually going on; they point to files that don’t exist. Either there’s some “default” parsing of the app definitions (i.e., the files that say such-and-such app can deal with such-and-such file types) that doesn’t rely on a file, or some totally random process just happens to have worked the same way every time I create the disposable template, and works the same way every time I run a disposable based on the template.

I do have a file named /usr/share/applications/mimeinfo.cache, but that seems to be the result of this process, not the cause. It’s dated the time I created my template. Maybe it’s manipulated by the installers? But even so it does not have a [Defaults] section, just a [MIME Cache] section.

Some docs reference ~/.config/mimeapps.list and this does not exist on my system either…until I try to open a PDF and tell it to open a different app. Now ~/.config/mimeapps.list exists. (and ~/.local/share/applications still does not.)

So I have the situation where the allegedly basic docs in ArchLinuxLand point me to a system default file that does not exist, and user overrides of whereverthehell the system defaults are, don’t go where expected (based on the docs) either, but at least they do go somewhere.

Why not just use .config/mimeapps.list? I will if I have to, but really I’d rather go to the system defaults since I am creating a template. I just can’t figure out where the heck they are!!

[edit: I discovered that by swapping the order the programs are listed in mimeinfo.cache, I could alter which one is the default. I did that in the template. However, I can’t get them to change order in mimeinfo.cache without editing it. I even tried regenerating the template and installing the programs in the opposite order, and that did not work. So the questions remain: What’s being read by the system to create mimeinfo.cache? Why does one app end up listed first for a file type regardless of installation order?]

Get the .desktop name of your pdf viewer and use this command in your app qube:

xdg-mime default program.desktop application/pdf

It will create a new config file ~/.config/mimeapps.list with the default application, so it’s persistent in the app qube.

Actually, most distros document this pretty well.
Why would you go to an archlinux page when you have a debian problem?
Why not read the debian docs and wiki?
Jeez

I never presume to speak for the Qubes team.
When I comment in the Forum I speak for myself.

Because the Debian docs refer to nonexistent files and end up pointing to the arch doc anyway.

I DID try looking for Debian but found absolutely nothing useful.

It still doesn’t answer the fundamental question: How does the system default get set?

From what I’ve seen, it’s the first app listed in mime-cache. But mime-cache seems to be literally set up in alphabetical order; I can’t find any mechanism that will affect it. There’s surely a way to set the system default while installing apps?

And actually, I remembered another reason I abandoned the Debian stuff.

Everything duck duck go gave me was predicated on the assumption that I was running a Debian desktop. Basically go here in your desktop bar, and open up such-and-such app and fiddle with it.

I don’t run desktops within my domUs. (Is that even possible?)

XDG checks a few directories to see if there is a defaults.list (which is a symlink of mimeapps.list) or mimeapps.list file with the default (manually set by the user or distro). In your case, there is none, so it tries to read mimeinfo.cache and uses the first program that can handle the specified mime type. You will see a MimeType= line in your .desktop files, that is what is used to generate the cache file so it knows which program can handle a specific mime type. There is also no way to change the order of them, so you have to use mimeapps.list to set your own default.

debian-12-minimal:

XDG_UTILS_DEBUG_LEVEL=3 xdg-mime query default text/plain
Checking /home/user/.local/share/applications/defaults.list and /home/user/.local/share/applications/mimeinfo.cache
Checking /home/user/.local/share/applications/defaults.list and /home/user/.local/share/applications/mimeinfo.cache
Checking /usr/local/share//applications/defaults.list and /usr/local/share//applications/mimeinfo.cache
Checking /usr/local/share//applications/defaults.list and /usr/local/share//applications/mimeinfo.cache
Checking /usr/share//applications/defaults.list and /usr/share//applications/mimeinfo.cache
Checking /usr/share//applications/defaults.list and /usr/share//applications/mimeinfo.cache
 Checking /usr/share//applications/org.gnome.gedit.desktop
   Select /usr/share//applications/org.gnome.gedit.desktop [ -1 => 0 ]
 Checking /usr/share//applications/org.xfce.mousepad.desktop
 Checking /usr/share//applications/vim.desktop
org.gnome.gedit.desktop

debian-12-xfce:

XDG_UTILS_DEBUG_LEVEL=3 xdg-mime query default text/plain
Checking /usr/share//applications/mimeapps.list
org.xfce.mousepad.desktop

If there is no mimeinfo.cache, it reads the .desktop files directly and takes the first one that comes up alphabetically with the correct mime type support (as shown in the minimal example).

So if you want to manage the default system application, you have to create this mimeapps.list file with your own default, otherwise it will try to find the first application that can handle the file you want to open.

1 Like

And this is documented here

It is possible to manipulate the information in mimeinfo.cache - e.g by
changing the order of entries -
application/pdf=libreoffice-draw.desktop;org.gnome.Evince.desktop;
To:
application/pdf=org.gnome.Evince.desktop;libreoffice-draw.desktop;
will change the xdg-mime query default value.
But that’s quite fragile.

You can also leave the defaults in the template, and put a
mimeapps.list file in to /etc/skel, to be picked up by all qubes
created from that template.

I never presume to speak for the Qubes team. When I comment in the Forum I speak for myself.

I did subsequenty find the one you linked. There’s another one on the same website that talks about using /etc/xdg instead of those directories (I think–it’s long gone and I am going by memory); and that one can’t be too out of date since it references debian-12. So: contradictory docs. Not that I saw either of these earlier.

(I asked a specific question of duck duck go the first time and got sent all over creation; the second time I simply asked for debian 12 mime (or something simple like that.)

My apologies for the delays in responding (which also caused me to forget details); I was eclipse chasing (with success BTW).

There’s more to this than I can find in the documentation.

There is also a file:

/usr/share/qubes/xdg-override/applications/mimeapps.list
which is part of the package
qubes-core-agent

Should this be mentioned somewhere in the Qubes documentation?