2

This is a really weird issue: whenever I download and open a PDF in Chromium, it will always open it with Gimp, while my system default PDF viewer is evince (aka Document Viewer). I don't know why this happens. I've tried solutions such as changing or resetting the system default application for PDFs, but this doesn't seem to affect Chromium (although it works fine with everything else, e.g. nautilus will open PDFs in evince).

I'm at a loss with this one, really. I've seen suggestions to mess around with xdg-mime settings but I wouldn't really know where to start with that. Help is much appreciated, because I open a lot of PDFs and it's starting to get very annoying when Gimp starts up every time I download one.

My specs are: Ubuntu 20.04.2 LTS, Ungoogled Chromium 89.0.4389.114.

2
  • Check your browser settings. These can override the system wide settings.
    – vanadium
    Apr 26, 2021 at 14:04
  • @vanadium thanks for the suggestion, but there doesn't seem to be a way to change filetype associations in-browser. I may do some digging in the config files, though. Apr 26, 2021 at 14:38

1 Answer 1

1

Ok, after digging through a whole heap of stuff, I found that Chromium uses xdg-open to open files on Ubuntu.

The solution for me was to reconfigure xdg-open using the xdg-mime command as follows:

First, you need to know that xdg-mime works using .desktop files, for some reason. This is how it works out what programme it should use to open a file when Chrome calls it with xdg-open filename.pdf.

I use i3wm, a desktopless environment. In my case, the .desktop files I found were stored in ~/.local/share/applications/. If you take a look in here, you will probably see a load of different ones for various programmes you've installed.

(Note: if you use normal Ubuntu, it may be the case that xdg-mime simply uses the desktop files in ~/Desktop. You may need to adapt these instructions, so if they don't work, or there's nothing in ~/.local/share/applications/, just do everything the same but replacing ~/.local/share/applications/ with ~/Desktop).

Anyway, if you run the command

xdg-mime query default application/pdf

you'll be told something like (in my case):

wine-extension-pdf.desktop

This is a desktop file that was installed by wine at some point. I don't know why xdg-mime thinks it's the right one to use, but somehow it's decided to use it as the default to open pdf files. Why this also leads to Gimp being used, I also have no clue.

So, cd ~/.local/share/applications/ and confirm that this is the location of this wine-extension-pdf.desktop file (or whatever it is on your computer). Then, you need to create a new .desktop file. Call it something like pdf-evince.desktop, and give it the contents:

[Desktop Entry]
Type=Application
Name=evince
MimeType=application/pdf;
Exec=evince %f

Feel free to replace evince with your favourite pdf viewer.

You now need to register this new desktop link to be the default with xdg-mime, so run:

xdg-mime default pdf-evince.desktop application/pdf

Now go back to Chromium and try to open a downloaded pdf. It should open in your chosen pdf viewer!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.