How to set default browser for PDF reader Evince on Linux?

12

2

I find this command

sudo update-alternatives –config x-www-browser

I choose Chrome. It works for xpdf, but Evince still starts Firefox after click.

I feel Linux is not standard. I use Linux Mint 8 (Helena) LXDE.

chenge

Posted 2010-06-14T07:59:11.287

Reputation: 323

For MATE users: http://askubuntu.com/a/533160/10425

– Martin Thoma – 2014-10-07T11:52:40.080

this question is not well phrased , what do you mean that evince starts firefox ? Having seen this, now I am not so sure about my answer. – g24l – 2011-12-16T00:12:22.610

I think the question is about which browser starts if you click on a URL in a PDF document. – erik – 2013-10-24T09:51:32.140

Answers

10

Solving your issue is like voodoo, even when there are "protocols" regarding how and which applications are supposed to open a specific kind of file. You'll see that they're very inconsistent between systems and different desktop environments.

So there's no really a "right" answer. I had a similar problem with firefox, so I'm giving you my solution:

  1. Create a ~/.local/share/applications/defaults.list if it doesn't exist
  2. Add the following

    [Default Applications]
    application/pdf=evince.desktop;
    

    ...or just the last line if there's something before.

Pablo Olmos de Aguilera C.

Posted 2010-06-14T07:59:11.287

Reputation: 351

1

I've heard that mimeapps.list is the new filename for freedesktop.org: http://standards.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.1.html

– Ciro Santilli 新疆改造中心法轮功六四事件 – 2015-03-30T19:42:25.140

It works like Voodoo, magical, but just simply works =) – Shi B. – 2015-07-30T03:54:14.143

10

As far as I understand LXDE uses xdg to do calls to applications. This command should fix your issue:

To find out which application opens a pdf file :

xdg-mime query default application/pdf

To set the application to evince

xdg-mime default evince.desktop application/pdf

This should work if your application is registered to the desktop (i.e. if there is a launcher)

g24l

Posted 2010-06-14T07:59:11.287

Reputation: 829

5this should actually be xdg-mime default evince.desktop application/pdf – xubuntix – 2012-05-14T17:26:09.970

4

You can edit your $HOME/.local/share/applications/mimeapps.list file. If this file does not exist, create one.

For illustration's sake, if you want Chromium to be the default browser, add the following line:

x-scheme-handler/http=chromium.desktop

That's all.

Auguste

Posted 2010-06-14T07:59:11.287

Reputation: 41

Worked like a charm on Arch Linux. – Rudy Matela – 2013-07-10T02:35:50.470

4

I had a reverse problem - I want firefox to open the links, but evince started chromium no matter what.

I used strace -o /tmp/output evince to see what functions are called and found this in the log:

open("/home/koniu/.local/share/applications/firefox.desktop;", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
open("/usr/local/share/applications/firefox.desktop;", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
open("/usr/share/applications/firefox.desktop;", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
open("/home/koniu/.local/share/applications/chromium.desktop", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
open("/usr/local/share/applications/chromium.desktop", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
open("/usr/share/applications/chromium.desktop", O_RDONLY|O_LARGEFILE) = 16

No idea why there's a semicolon included in the firefox.desktop but I created /home/koniu/.local/share/applications/firefox.desktop with the following content:

[Desktop Entry]
Name=Firefox
Exec=/usr/bin/firefox %U
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=firefox
Categories=Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml_xml;x-scheme-handler/http;x-scheme-handler/https;
StartupNotify=true

And now evince starts firefox as desired.

koniu

Posted 2010-06-14T07:59:11.287

Reputation: 566

3

To change Gnome applications you need to use gconftool:

$ gconftool -s /desktop/gnome/url-handlers/http/command -t string 'chromium-browser %s'

To check the changes:

$ gconftool -g /desktop/gnome/url-handlers/http/command

Other Gnome applications:

/desktop/gnome/url-handlers/chrome/command
/desktop/gnome/url-handlers/https/command
/desktop/gnome/url-handlers/http/command
/desktop/gnome/url-handlers/ftp/command

Reference:

http://www.salixos.org/forum/viewtopic.php?f=15&t=1376&view=print

javier

Posted 2010-06-14T07:59:11.287

Reputation: 31

you keep telling the guy to setup gnome, but he is using LXDE... – g24l – 2011-12-16T00:00:30.243

1@g24l: Evince is a GNOME program, though. (However, it doesn't use GConf for URL handlers anymore.) – user1686 – 2011-12-16T00:17:46.857

1

None of these solutions worked for me.

I had to edit ~/.config/mimeapps.list and append these rules to the two headers:

[Default Applications]
application/pdf=org.gnome.Evince.desktop

[Added Associations]
application/pdf=evince.desktop;org.gnome.Evince.desktop;

brettinternet

Posted 2010-06-14T07:59:11.287

Reputation: 115

0

I had this problem, using evince under KDE. I had to log out from KDE, login to GNOME, and set the default browser of GNOME (Search -> Details -> Default Applications -> Browser). Then go back to KDE and it worked fine.

mathause

Posted 2010-06-14T07:59:11.287

Reputation: 101

0

Set the default browser in Gnome applications with gnome-default-applications-properties.

Ignacio Vazquez-Abrams

Posted 2010-06-14T07:59:11.287

Reputation: 100 516

you almost killed my system!

after apt-get gnome-control-center, the system is almost broken. – chenge – 2010-06-14T09:22:49.773

define "almost broken" – msw – 2010-06-14T11:10:26.970

3The issue may be you are telling him to install gnome stuff when his window manager is probably LXDE. – Jarvin – 2010-06-14T17:40:49.730

i report it: http://forums.linuxmint.com/viewtopic.php?f=47&t=50017

it write file .xsession-errors with "fcitx signal 11", and eat the hd space.

– chenge – 2010-06-15T10:40:54.740

4@Dan keep in mind that evince is "gnome stuff", and has gnome dependencies; that said, I don't know what the right answer here is. (Also, LXDE is a desktop environment, not a window manager, not that matters here.) – frabjous – 2010-08-31T02:31:36.360