Make Thunderbird open links in your browser

Thunderbird can use a variety of mechanisms to determine which browser to use.

System default browser

If the http or https content type action is not configured (more on this later), then Thunderbird will open links using the system’s default browser.

On Xfce this is set via Settings -> Preferred applications.

If the system’s default browser is not set, then you will be prompted to set it when you click a link in Thunderbird.

Content type action

If Thunderbird has a content type action defined then it will use the browser specified here instead of the system’s default browser.

This is particularly useful if you’d like different Thunderbird profiles to open links in different browser profiles (I have a profile for personal stuff and a profile for work). More on this later.

  1. Go to Preferences -> Attachments -> Incoming.
  2. Type http or https in the search box.
  3. If a content type is found, then choose its associated action (which could be a particular browser or a custom command or a prompt).

If the http or https content type is not found then you can add them as follows (unfortunately there isn’t a UI for this):

  1. Close Thunderbird.
  2. Back up ~/.thunderbird/[profile]/mimeTypes.rdf, where [profile] is the profile directory e.g. 8cwe8m4b.default. You can find it with the following command:

    find ~/.thunderbird -name "mimeTpes.rdf"
    
  3. Edit it and add the following:

    <RDF:Description RDF:about="urn:scheme:handler:http"
                     NC:alwaysAsk="true" />
    <RDF:Description RDF:about="urn:scheme:http"
                     NC:value="http">
      <NC:handlerProp RDF:resource="urn:scheme:handler:http"/>
    </RDF:Description>
    <RDF:Description RDF:about="urn:scheme:handler:https"
                     NC:alwaysAsk="true" />
    <RDF:Description RDF:about="urn:scheme:https"
                     NC:value="https">
      <NC:handlerProp RDF:resource="urn:scheme:handler:https"/>
    </RDF:Description>
    

    And add them to the root URN scheme (check whether it already exists first and only add to it if so):

    <RDF:Seq RDF:about="urn:schemes:root">
      <RDF:li RDF:resource="urn:scheme:http"/>
      <RDF:li RDF:resource="urn:scheme:https"/>
    </RDF:Seq>
    
  4. Start Thunderbird and you should now have the http and https content types with their actions set to ‘Always ask’. This will allow you to choose an application when you next click a link.

Alternatively you could set which application you’d like directly in the RDF. The trail through the RDF is as follows:

urn:schemes:root -> urn:scheme:http -> urn:scheme:handler:http -> urn:scheme:externalApplication:http

So for e.g. http:

<RDF:Description RDF:about="urn:scheme:externalApplication:http"
                 NC:prettyName="google-chrome"
                 NC:path="/opt/google/chrome/google-chrome" />
<RDF:Description RDF:about="urn:scheme:handler:http"
                 NC:alwaysAsk="false">
  <NC:externalApplication RDF:resource="urn:scheme:externalApplication:http"/>
  <NC:possibleApplication RDF:resource="urn:handler:local:/usr/bin/firefox"/>
</RDF:Description>

This will set the http action to ‘Use google-chrome’, which calls /opt/google/chrome/google-chrome with /usr/bin/firefox also available.

Note that I have no idea where the prettyName is used and also it seems that this RDF is really flaky and sensitive to spaces at least, so don’t use any!

If you don’t know where your browser is located, use the whereis command as follows:

whereis [browser]

Example:

steph@localhost ~ $ whereis firefox
firefox: /usr/bin/firefox /usr/X11R6/bin/firefox

Passing arguments

It’s not possible to add command arguments to mimeTypes.rdf (at least I haven’t found a way) but you can define a bash script and call the arguments from there.

This approach can be used to have different Thunderbird profiles open links in different browser profiles (I have a profile for personal stuff and a profile for work).

~/scripts/chrome:

#!/bin/bash

google-chrome --profile-directory="Profile 1" "$@"

~/.thunderbird/[profile]/mimeTypes.rdf:

<RDF:Description RDF:about="urn:scheme:externalApplication:http"
                 NC:prettyName="chrome"
                 NC:path="~/scripts/chrome" />
<RDF:Description RDF:about="urn:scheme:handler:http"
                 NC:alwaysAsk="false">
  <NC:externalApplication RDF:resource="urn:scheme:externalApplication:http"/>
</RDF:Description>

network.protocol-handler.app.[protocol]

It is said that the following two configuration settings will define which browser is used by Thunderbird:

  • network.protocol-handler.app.http -> e.g. /usr/bin/firefox-bin
  • network.protocol-handler.app.https -> e.g. /usr/bin/firefox-bin

You can edit them via Preferences -> Advanced -> Config Editor.

I haven’t had a great deal of luck with these settings. I’m sure that in the past they have worked but they don’t seem to make any difference now on Thunderbird 31.5.0.

Editing prefs.js directly

Alternatively you can edit the prefs.js file directly. It resides in your profile directory (probably something like .thunderbird/[random_string].default/prefs.js). You can find it with the following command:

find .thunderbird -name "prefs.js"

Example:

steph@localhost ~ $ find .thunderbird -name "prefs.js"
.thunderbird/8cwe8m4b.default/prefs.js

Add the following to prefs.js:

user_pref("network.protocol-handler.app.http", "/usr/bin/firefox");
user_pref("network.protocol-handler.app.https", "/usr/bin/firefox");

Of course, change /usr/bin/firefox to the location of your browser. If you don’t know where that is, use the whereis command as follows:

whereis [browser]

Example:

steph@localhost ~ $ whereis firefox
firefox: /usr/bin/firefox /usr/X11R6/bin/firefox

You can specify your ftp program in a simlar fashion by adding the following:

user_pref("network.protocol-handler.app.ftp", "/usr/bin/firefox");

Still not working?

Ask Thunderbird to ask you

You could try setting network.protocol-handler.warn-external.http and network.protocol-handler.warn-external.https to true and see whether it asks you which browser you’d like to use next time you click a link. It didn’t work for me though (possibly because of this bug: Bug 440892 - network.protocol-handler.warn-external are ignored).

Problems with Google Chrome?

I’ve a feeling that this “solution” worked for me in the past because I wasn’t aware of mimeTypes.rdf (see Content type action above), so it’s probably a red herring but I thought I’d add it anyway because why not?!

Symlink /usr/bin/google-chrome to the location of the actual binary:

ln -s /opt/google/chrome/google-chrome /usr/bin/google-chrome

References

Last modified: 10/04/2015 Tags:

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top