I don't want to sound like a smart-ass, it's just I found the default firefox behavior irritating.
The problem:
I use firefox as the default browser in my system. I use it to surf the net and to open locally saved html pages. The problem is that if you open a locally saved html page with firefox by double clicking it, and an instance of firefox is already running in your system, the page will open in the old window, instead of opening a new window or a new tab.
Solution:
I've seen a lot of solutions for this problem, like creating a small script to do that, but IMHO just hacking the firefox script (the main executable) is the easiest and better working solution.
In most cases people install firefox somewhere like /usr/lib/firefox or /usr/local/lib/firefox or /usr/local/firefox and then place a link of firefoxe's executable in one of the /bin directories: /usr/bin or /usr/local/bin.
The main firefox executable is just a script that initializes the enviroment and maybe calls other scripts like run-mozilla.sh. The binary executable firefox-bin is never executed directly.
What all the mozilla browsers do is check if a mozilla instance is running. If not, then no problem they start it. If yes, they use the -remote option to communicate with an already running mozilla/firefox instance and execute command throught that. This way, no matter how many browser windows a user opens in a computer, they all are child processes of a basic process that has locked the default profile, and other stuff with a lock file:
Code:
skalkoto@darkstar:~/.mozilla/firefox/9x2zz9ty.default$ ls -l lock
lrwxrwxrwx 1 skalkoto users 16 2005-03-29 16:52 lock -> 192.168.10.1:348
skalkoto@darkstar:~/.mozilla/firefox/9x2zz9ty.default$
Actually if firefox is already running this part of the firefox script is executed:
Code:
########################################################################### Main
if [ $ALREADY_RUNNING -eq 1 ]; then
# There's an instance already running. Use it.
# Any command line args passed in?
if [ $# -gt 0 ]; then
# There were "some" command line args.
if [ ${_USE_EXIST} -eq 1 ]; then
# We should use an existing instance, as _USE_EXIST=$_USE_EXIST=-
1
_remote_cmd="openURL(${_optLast})"
"${run_moz}" "$MOZ_CLIENT_PROGRAM" -a "${progbase}" "${_remote_cm
d}"
unset _remote_cmd
exit $?
fi
else
# No command line args. Open new window/tab
#exec "${run_moz}" "$MOZ_CLIENT_PROGRAM" -a "${progbase}" "xfeDoCommand(o
penBrowser)"
"${run_moz}" "$MOZ_CLIENT_PROGRAM" -a "${progbase}" "xfeDoCommand(openBro
wser)"
exit $?
fi
fi
The solution is to change _remote_cmd="openURL(${_optLast})" to
_remote_cmd="openURL(${_optLast} , new-window)" or
_remote_cmd="openURL(${_optLast} , new-tab)"
This is the $Id: mozilla.in,v 1.3.4.9 2004/10/26 09:26:11 bryner%brianryner.com Exp $
script used by firefox 1.0.1 and 1.0.2. , maybe by 1.0 also. I don't know about older scripts, but they should be similar. I'm using slackware 10.1 and firefox 1.0.2, the one packed by Pat in slackware-current, if it matters at all (which I don't think it does).
for more info on the -remote option follow this link:
http://www.mozilla.org/unix/remote.html
Thanks for your patience