xdg-mime priorities /usr/share//applications/mimeinfo.cache over $HOME/.config/mimeapps.list
$ grep -i application/pdf /usr/share//applications/mimeinfo.cache $HOME/.config/mimeapps.list /usr/share//applications/mimeinfo.cache:application/pdf=gimp.desktop;inkscape.desktop;calibre-gui.desktop;krita_pdf.desktop;xpdf.desktop;libreoffice-draw.desktop;okularApplication_pdf.desktop;org.gnome.Evince.desktop;calibre-ebook-viewer.desktop; /home/username/.config/mimeapps.list:application/pdf=okularApplication_pdf.desktop;
$ Checking /home/username/.config/mimeapps.list Checking /home/username/.local/share/applications/defaults.list and /home/username/.local/share/applications/mimeinfo.cache Checking /home/username/.local/share/applications/defaults.list and /home/username/.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 gimp.desktop
Afer manually removing the offensive line in /usr/share//applications/mimeinfo.cache (# for comment does not work): $ xdg-mime query default application/pdf okularApplication_pdf.desktop
Aside from the fact that opening pdf files with gimp is about as enlightening as viewing pngs with hexdump (there is a world of a difference between "I can somehow import try to import $format" and "I am a good default choice for $format", which does not seem to be reflected in the *.desktop files?), my main issue here is the the global config file seems to override the user config file, when it should be the other way round. (as mimeopen does).
$ env | grep XDG XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0 XDG_SEAT=seat0 XDG_SESSION_DESKTOP=lightdm-xsession XDG_SESSION_TYPE=x11 XDG_GREETER_DATA_DIR=/var/lib/lightdm/data/username XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0 XDG_SESSION_CLASS=user XDG_VTNR=7 XDG_SESSION_ID=4 XDG_RUNTIME_DIR=/run/user/1000 $ xdg-mime --version xdg-mime 1.1.3
I am running Debian 10 buster on x86_64 with wmaker as DE, if any of that is relevant.
As a workaround making $HOME/.local/share/applications/mimeinfo.cache a symlink to $HOME/.config/mimeapps.list does the job, at least until some program helpfully opens the cache with O_TRUNC, so better make a backup first.