I've been hit by this recently, but for me the problem is that PDFs are being handled by Inkscape. My mimeinfo.cache file (the file that is being used by GIO and therefore Firefox) contains the following line:
The "zzz-" thing is a hack added by my distribution - see http://bugs.gentoo.org/show_bug.cgi?id=321111. Oddly enough, the ordering here does not actually seem to be alphabetical, because inkscape is listed first. This is why Firefox (or GIO, more precisely) has been trying to open PDFs in Inkscape.
However, "xdg-mime query default application/pdf" IS alphabetical, because it does not use the mimeinfo.cache file. xdg-mime is actually a shell script, and it finds applications that support PDFs by grepping for the mime type in all of the .desktop files. The list of files passed to grep is alphabetical, so the list of files returned by grep is also alphabetical and starts with evince.desktop. Therefore, evince.desktop is what xdg-mime thinks is the default.
The core problem here is of course that there is no priority information in the .desktop files. The relevant freedesktop spec specifically forbids this - see http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s07.html. The result is random priorities when there are no explicit settings.
No doubt this policy was created with good intentions, but the fact is that there are legitimate reasons to encode priorities in the .desktop files. Evince should clearly have higher priority than GIMP or Inkscape for PDFs. The "the first one that I see" policy used by GIO and xdg-mime when there is no explicit user preference is always going to suck.
Adding an explicit user preference worked around the problem for me. I don't use KDE or GNOME, so I don't have access to any of the fancy graphical configuration utilities, but the following command:
xdg-mime default evince.desktop application/pdf
...seems to have been effective.
I would personally argue against using the xdg-utils in Firefox, because they are shell scripts (seriously, wtf?) and because they don't seem to be inherently smarter aside from purely by chance returning the right answer in my case.
I've been hit by this recently, but for me the problem is that PDFs are being handled by Inkscape. My mimeinfo.cache file (the file that is being used by GIO and therefore Firefox) contains the following line:
application/ pdf=inkscape. desktop; evince. desktop; zzz-gimp. desktop;
The "zzz-" thing is a hack added by my distribution - see http:// bugs.gentoo. org/show_ bug.cgi? id=321111. Oddly enough, the ordering here does not actually seem to be alphabetical, because inkscape is listed first. This is why Firefox (or GIO, more precisely) has been trying to open PDFs in Inkscape.
However, "xdg-mime query default application/pdf" IS alphabetical, because it does not use the mimeinfo.cache file. xdg-mime is actually a shell script, and it finds applications that support PDFs by grepping for the mime type in all of the .desktop files. The list of files passed to grep is alphabetical, so the list of files returned by grep is also alphabetical and starts with evince.desktop. Therefore, evince.desktop is what xdg-mime thinks is the default.
The core problem here is of course that there is no priority information in the .desktop files. The relevant freedesktop spec specifically forbids this - see http:// standards. freedesktop. org/desktop- entry-spec/ latest/ ar01s07. html. The result is random priorities when there are no explicit settings.
No doubt this policy was created with good intentions, but the fact is that there are legitimate reasons to encode priorities in the .desktop files. Evince should clearly have higher priority than GIMP or Inkscape for PDFs. The "the first one that I see" policy used by GIO and xdg-mime when there is no explicit user preference is always going to suck.
Adding an explicit user preference worked around the problem for me. I don't use KDE or GNOME, so I don't have access to any of the fancy graphical configuration utilities, but the following command:
xdg-mime default evince.desktop application/pdf
...seems to have been effective.
I would personally argue against using the xdg-utils in Firefox, because they are shell scripts (seriously, wtf?) and because they don't seem to be inherently smarter aside from purely by chance returning the right answer in my case.