Open new tabs in firefox/mozilla

j79zlr

Glaanies script monkey
Political User
#1
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.
 

X-Istence

*
Political User
#5
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 posts

Latest profile posts

Perris Calderon wrote on Electronic Punk's profile.
Ep, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there https://tinyurl.com/ycpxl
Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...
Xie
What a long strange trip it's been. =)

Forum statistics

Threads
61,970
Messages
673,297
Members
89,017
Latest member
Poseeut