firefox

Jing Su jingsu-26n5VD7DAF2Tm46uYYfjYg at public.gmane.org
Mon Jul 5 19:23:57 UTC 2004


First, my apologies for not posting as a thread reply to this topic; I
lost the original thread of messages about this.

For those that are interested, here is a fixed version of that browser
launching script I sent out before (it's an attachment).  I use the
mozilla-xremote-client executable that others have pointed out.  It seems
that though the "-remote" command from the primary executable is broken,
the xremote-client executable is able to communicate ok with the running
instance.

What's nice about the script is that you can just keep calling it without
worrying about running instances and stuff.  So, you can do:
 browser.sh thisfile.html
or
 browser.sh /var/www/html/index.html
or
 browser.sh www.google.ca

and it will do the "right thing", regardless of whether or not mozilla (or
firefox) is currently running.  One caveat is that apparently the
'new-tab' and 'new-window' flags for URLs is still broken, even through
the xremote-client program.  So, URL opens always opens a new window and
then opens the URL in the new window, via a workaround.  It's commented in
the script, so you can play around with it.

Anyways, you'll have to edit the script and change the TARGET and REMOTE
variables to point to the right mozilla or firefox programs.

On my system, I have browser.sh copied into /usr/local/bin and made
executable.  I then make /usr/local/bin/mozilla a symlink to this script,
so that programs that call 'mozilla' will automatically go through this
script.  Tailor to your personal taste. :)

Any comments or suggestions welcome.
I hope some of you will find it useful.

-Jing
-------------- next part --------------
#!/bin/sh

#TARGET=/usr/local/mozilla/mozilla
TARGET=/opt/firefox-0.9/firefox
REMOTE=/opt/firefox-0.9/mozilla-xremote-client

if [ "$1" == "-remote" ]; then
    # calling program is smart enough to do it...
    exec $TARGET $*

elif `$REMOTE "ping()" &> /dev/null`; then
    # there is already one running

    if [ -z "$1" ]; then
	exec $REMOTE "openURL("about:blank", new-window)"

    elif [ -f "$1" ]; then
        # okay, tedious work of trying to find the complete pathname
        # make two variables, trying to separate the path from file.
        file=`basename $1`
        path=${1%%${file}}
	if [ ! -d "$path" ]; then
        	# try to fully expand the path
        	path=`pwd $path`
	fi
        # okay, issue the command
	exec $REMOTE "openFile(file://$path/$file, new-tab)"

    else
	# "new-tab" feature for URLs is broken in current firefox
	#exec $REMOTE "openURL($1, new-tab)"
	# so what we do instead is always open a new window and then
	# open the URL
	$REMOTE "xfeDoCommand(openBrowser)"
	exec $REMOTE "openURL($1)"

    fi
else
    # no mozilla currently running
    exec $TARGET $* &
fi


More information about the Legacy mailing list