Open new tabs in firefox/mozilla

j79zlr

Glaanies script monkey
Political Access
Joined
16 Feb 2003
Messages
2,725
I know variations of this have been posted on the web, but I never found a working script, so I fixed it [for me atleast]. Create a script in your home directory named whatever you want [I use firefox_newtab.sh].

Code:
#!/bin/sh
export MOZILLA_FIVE_HOME="/usr/lib/mozilla-firefox"

url="$1"
if [ "x$url" = "x" ]; then
  url="about:blank"
fi

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

Now if you point an application to use that instead of the binary it will open in a new tab instead of the "Choose Profile" dialog. Works in GAIM by changing the browser to 'manual' and pointing it to the script, and in Thunderbird, by adding this to your prefs.js file:

user_pref("network.protocol-handler.app.http", "/path/to/firefox_newtab.sh");

I am assuming that this works for mozilla in the exact same manner, by changing the FIVE_HOME path to mozilla's and the line to mozilla-xremote-client -a mozilla openURL etc; also, I would assume that you could remove the /usr/bin/mozilla binary and replace it with the shell script, and not need to point to the script then.
 
Very nice tip! Thanks
smile.gif
 
Code:
#!/usr/local/bin/bash

export MOZILLA_FIVE_HOME=/usr/X11R6/lib/firefox/bin/:/usr/X11R6/lib/firefox/lib/mozilla-1.6/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MOZILLA_FIVE_HOME

# get URL to load
url=$1; [ -z $url ] && url=about:blank
what=$2;

if [ -z $what ]; then
        /usr/X11R6/lib/firefox/lib/firefox-0.9/mozilla-xremote-client -a firefox openURL\($url\,new-window\) && exit 0
else
        /usr/X11R6/lib/firefox/lib/firefox-0.9/mozilla-xremote-client -a firefox openURL\($url\,$what\) && exit 0
fi

# if xremote failed, then launch the browser
exec /usr/X11R6/lib/firefox/bin/firefox $url &

Given either:

firefox-starter <url> <type> (new-tab, or new-window)

If no URL or type is given, it starts a browser window with a blank screen (about:blank) if only URL is given, it opens a new browser window with that in it. If given new-tab it opens a new tab, and if new-window is set, a new-window (same as not defining it).

Enjoy :).

(Sorry for the hardcoded stuff, change it as you deem fit, it is cause mozilla-xremote-client is not in the same place as firefox the startup script)
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back