Make external programs in Linux use the right browser

From MozillaZine Knowledge Base
Jump to navigationJump to search

As of 2010, Firefox and SeaMonkey seem do the right thing (open a new tab in a running instance) if you just start the application shell and pass it a URL.

And most Linux distributions for end-users have a system setting for default Web application or default text/html mime handler that you can set to Firefox; this often happens automatically through a .desktop file (possibly in /usr/share/applications or $HOME/.local/share/applications) giving the details of the browser, how to start it, and the file types it can handle.

Older approach

Configure each external program to pass the URL to this Bourne shell script:

# This script allows external apps to open new URLs in Firefox
# or open a new instance of Firefox if it isn't already started
/path/to/firefox/firefox -a firefox -remote "openURL($@,new-tab)" ||
exec /path/to/firefox/firefox "$@";

This shell script takes advantage of the Mozilla IPC protocol to either open the external URL in an already active Firefox instance, or start a new instance of Firefox.

To make this script work with Mozilla, replace all instances of "firefox" with "mozilla".