How to use Firefox from external applications

#################################################################
The article was obtained at the following URL: http://www.kfwebs.net/articles/article/8
The article might be distributed further as long as it is provided as it is, with the credits stated.
The Article was written and first published by KF Webs, at http://www.kfwebs.net
#################################################################

As for Windows, Mac OS X and some desktop environments on GNU/Linux you would simply set a default browser for the system. However there is also a manual way of setting this option.
Added: 2005-01-02 17:34:59 - Modified: 2006-09-23 23:20:54 - Level: Intermediate

The actual script is as follows

#!/bin/bash

export MOZILLA_FIVE_HOME="/home/kristianf/Applications/firefox/current"

url="$1"
if [ "x$url" = "x" ]; then
url="about:blank"
else
url=http://${url##http://};
url=${url/http:\/\/https:\/\//https:\/\/}
fi

if $MOZILLA_FIVE_HOME/mozilla-xremote-client -a openURL\("$url"\); then
exit 0
fi
exec $MOZILLA_FIVE_HOME/firefox "$url"

How to use it

Mozilla Thunderbird

user_pref("network.protocol-handler.app.http","/home/kristianf/Applications/firefox_remote.sh");
user_pref("network.protocol-handler.app.https","/home/kristianf/Applications/firefox_remote.sh");

If you don't have this file in your profile directory, then create it. it itsn't there by default. As you see this file set a new protocol handeler, in this case to a shell-script making use of Mozilla's xremote procedure. The shell-script in my case look like:

X-Chat

To use it from X-Chat you would add the following to urlhandlers.conf

NAME Browser
CMD !/home/kristianf/Applications/firefox_remote.sh "%s"

As always, comments and how to do it in other applications as well are welcome.

Related articles: