10

How do I set a manually downloaded Firefox as my default web browser so that clicking a link in another application will open the link in this Firefox?

I tried these commands, but they didn't seem to work:

update-alternatives --install /usr/bin/x-www-browser x-www-browser /home/user/firefox/firefox 100
update-alternatives --set x-www-browser /home/user/firefox/firefox

What do I have to do?

Anju Fabulina
  • 300
  • 1
  • 5
Chalist
  • 417
  • 4
  • 14
  • - If typing `$ x-www-browser` in the terminal opens the **correct** browser but: - `$ xdg-open https://www.example.com` opens the **wrong** browser application, - editing `~/.config/mimeapps.list` as suggested by @Chalist and then **restarting** should do the trick. – abnutzer Feb 26 '21 at 19:14

3 Answers3

6

update-alternatives changes the application to use to open a web browser, not the application to use to open a web page. The two are not directly related: “I want to browse the web” is different from “I want to browse this web page”, and there are different kinds of content that happen to all open in a web browser.

What you need to change is which application is associated with the MIME type text/html, and perhaps others. These are configured through the /etc/mailcap file.

On Debian, /etc/mailcap is automatically generated from the applications you have installed. When multiple applications can open the same type, there is a priority system (similar, but distinct, from the priority system for alternatives). You can override these priorities by adding entries to /etc/mailcap.order. For example, the following line will cause Firefox to be used in preference of any other application for all the types it supports:

firefox:*/*

After you've changed /etc/mailcap.order, run /usr/sbin/update-mime as root to update /etc/mailcap.

If you want to use a program that doesn't come from a Debian package, edit it directly into /etc/mailcap, in the User Section.

# ----- User Section Begins ----- #
text/html; /home/user/firefox/firefox '%s'; description=HTML Text; test=test -n "$DISPLAY";  nametemplate=%s.html
# -----  User Section Ends  ----- #

If you want to set preferences for your own account, define them in ~/.mailcap: the entries in that file override the ones in /etc/mailcap. You have to put full mailcap lines there, such as

text/html; /home/user/firefox/firefox '%s'; description=HTML Text; test=test -n "$DISPLAY";  nametemplate=%s.html
Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
1

Run both of the commands as root (you should have received a "Permission denied" error when trying to do this without root privileges). Now if you run (or another application runs) x-www-browser, /home/user/firefox/firefox should be the one that gets used.

You can also use the convenient interactive mode update-alternatives --config <name> to set default applications instead of using --set.

Anju Fabulina
  • 300
  • 1
  • 5
  • i do this with root access but don't work – Chalist Aug 27 '12 at 20:28
  • @chalist: Do you receive an error message? What is the output of `update-alternatives --display x-www-browser`? – Anju Fabulina Aug 27 '12 at 21:38
  • `x-www-browser - manual mode link currently points to /home/user/firefox/firefox /home/user/firefox/firefox - priority 100 /usr/bin/chromium - priority 40 Current 'best' version is '/home/user/firefox/firefox'. ` – Chalist Aug 28 '12 at 00:22
  • How do you see that it's not working? Which browser gets chosen when you start `x-www-browser` yourself? – Anju Fabulina Aug 28 '12 at 18:28
  • when i click a link in application look like choqok i will open in firefox(extracted in home) – Chalist Aug 29 '12 at 12:19
0

For Arch base distros, we have to change ~/.config/mimeapps.list and replace anywhere your default browser does not set.

For example:

  [Default Applications]
  x-scheme-handler/http=userapp-Pale Moon.desktop
  x-scheme-handler/https=userapp-Pale Moon.desktop
  x-scheme-handler/ftp=userapp-Pale Moon.desktop
  x-scheme-handler/chrome=userapp-Pale Moon.desktop
  text/html=userapp-Pale Moon.desktop
  ...
  ... (and anywhere Pale Moon.desktop has been setted)

changes to:

  [Default Applications]
  x-scheme-handler/http=userapp-chromium.desktop
  x-scheme-handler/https=userapp-chromium.desktop
  x-scheme-handler/ftp=userapp-chromium.desktop
  x-scheme-handler/chrome=userapp-chromium.desktop
  text/html=userapp-chromium.desktop
  ...

Chalist
  • 417
  • 4
  • 14