Linux – Fixing PDFs opening in GIMP in Firefox/Zotero

I’m not exactly sure why, but with the latest Firefox updates, every time I download a PDF using Firefox or try to open one using Zotero integrated with Firefox, the PDF opens in GIMP.  This didn’t use to happen, but it’s really annoying.  It’s doubly annoying since you can’t solve it inside Firefox.

It would make sense to be able to change this in one of two ways.  First, by simply setting your system-wide preference for what program opens PDFs, that should do it, but mine was already set to Okular.  The second logical solution would be to change the default applications in Firefox, but that doesn’t do anything.  It turns out, the solution is to edit a different file, changing the order of default applications for opening PDFs.  Here’s what you need to do:

  1. Open a terminal and gain root privilege to edit the following file: /usr/share/applications/mimeinfo.cache.  Here’s the command I use in Kubuntu:
    sudo kate /usr/share/applications/mimeinfo.cache

    NOTE: As of Kubuntu 18.04, you now have to use the following command to edit protected files with Kate:

    SUDO_EDITOR=kate sudoedit /usr/share/applications/mimeinfo.cache
  2. Once you have edit permissions for that file, search for this line:
    application/pdf=gimp.desktop;okularApplication_pdf.desktop;
  3. The order of the applications after the “=” indicate the order in which they will be used to load PDFs.  Right now, GIMP will be used first.  All you need to do to fix this is to change the order so Okular is first, like this:
    application/pdf=kde4-okularApplication_pdf.desktop;gimp.desktop;
  4. Once you change it, save your changes and then restart Firefox.  Your PDFs should now load in Okular.

(Notes: Nod to this forum post.)

Reader Comments

  1. Thanks! I also had gwenview opening directories, so the same reordering for inode/directory was in order:
    inode/directory=kde4-dolphin.desktop;kde4-gwenview.desktop;

  2. Thanks for your explanations. I have followed your instructions and they work great. For a while. From time to time (I haven’t figured out what triggers the event) my manual changes are reverted and PDFs are opened again with GIMP, files are opened with Gwenview instead of Dolphin… and so on.

    Isn’t there any way to prevent this from happening again?

    1. Hi Carlos,

      I don’t know precisely what causes this. I think (could be wrong) that it happens with every update of Firefox, updated to other software, and possibly every time you change the program associated with a file type (or MIME type). That is when mimeinfo.cache gets updated, and that’s probably what does it. The real question is what setting in what program accessing the /usr/share/applications/ directory reverts the changes. I honestly don’t know. Luckily, this only gets reverted for me every few months.

  3. This works but there’s a huge but: gimp comes back as the default viewer quite frequently, does this only happen to me?

    1. Thibault, it does happen to others. What version of Linux are you using? I recently updated to Linux Mint 18 KDE on all of my computers and this isn’t happening anymore.

      1. I’m using Debian Stretch with KDE. What I’ve done now is I’ve removed application/pdf from the MimeType in /usr/share/applications/gimp.desktop

        This should stop Gimp from adding itself to the mimeinfo cache for PDFs.

  4. Thanks for this post! :-)

    However, you should _never_ use or advice to use “sudo kate” or similar due to unfixable security issues.

    If you need to edit files for which higher privileges are required, go for sudoedit. ;-)

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.