LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 06-03-2004, 12:53 PM   #1
Pathian
Member
 
Registered: Sep 2003
Location: Dayton, Ohio and Hoffman Estates, IL
Distribution: Slackware 9.1 (laptop) Mandrake 9.2 (desktop)
Posts: 58

Rep: Reputation: 15
Mozilla Firefox open new window script


Hello all, I was wondering if anyone has had any luck with the script for the firefox launcher that is supposed to open I new window from an existing session instead of popping up that "select user profile" screen. I copied the script from the mozilla website and pointed it at firefox

#!/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 openURL\("$url"\); then
exit 0
fi
exec $MOZILLA_FIVE_HOME/firefox "$url"

but whenever I launch the script, instead of opening a new window, it merely takes the current window (or tab) and sends it to about:blank (or if I supply a URL, it sends the current tab to that URL). When I was using Mozilla 1.6 I used this script to get the desired behavior...

moz="/usr/lib/mozilla-1.6/mozilla-bin"

isRunning=`2>&1 $moz -remote ping`
case $isRunning in
# Start a new mozilla session
"No running window found." )
$moz "$*"
;;

# Spawn a new mozilla window from the existing session
"Failed to send command." )
$moz -remote "OpenURL ( "$*" , new-window)"
;;

# Dude, something's wrong.
* )
echo "This was the return value: $isRunning"
echo "d'oh"
;;
esac

Does anyone know how to adjust the firefox script so that a new window opens from the current session when the launcher is run? Thanks
 
Old 06-03-2004, 01:05 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
I think firefox takes the same "new-window" argument to openURL that mozilla does.
 
Old 06-20-2004, 04:25 PM   #3
SADANA
LQ Newbie
 
Registered: Nov 2001
Location: Amman - Jordan
Distribution: Slackware
Posts: 25

Rep: Reputation: 15
i edited the shell script, that came with mozila-1.5, so that i can run firefox just the way i want it... actually all i did was set the paths to point to firefox and removed that mail and compose options, and now it works :-) here it goes, enjoy:


#!/bin/sh
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#

##
## Usage:
##
## $ mozilla
##
## This script is meant to run a mozilla program from the mozilla
## rpm installation.
##
## The script will setup all the environment voodoo needed to make
## mozilla work.

cmdname=`basename $0`

## don't leave any core files around
ulimit -c 0

##
## Variables
##
MOZ_DIST_BIN="/usr/lib/mozilla-firefox"
MOZ_PROGRAM="/usr/lib/mozilla-firefox/firefox-bin"
MOZ_CLIENT_PROGRAM="/usr/lib/mozilla-firefox/mozilla-xremote-client"

##
## Set LD_LIBRARY_PATH
##
if [ "$LD_LIBRARY_PATH" ]
then
LD_LIBRARY_PATH=/usr/lib/mozilla-firefox:/usr/lib/mozilla-firefox/plugins:$LD_LIBRARY_PATH
else
LD_LIBRARY_PATH=/usr/lib/mozilla-firefox:/usr/lib/mozilla-firefox/plugins
fi
export LD_LIBRARY_PATH

##
## Make sure that we set the plugin path for backwards compatibility
##
MOZ_PLUGIN_PATH=/usr/lib/mozilla-firefox/plugins
export MOZ_PLUGIN_PATH

function check_running() {
$MOZ_CLIENT_PROGRAM 'ping()' 2>/dev/null >/dev/null
RETURN_VAL=$?
if [ "$RETURN_VAL" -eq "2" ]; then
echo 0
return 0
else
echo 1
return 1
fi
}

# check to see if there's an already running instance or not
ALREADY_RUNNING=`check_running`

# If there is no command line argument at all then try to open a new
# window in an already running instance.
if [ "${ALREADY_RUNNING}" -eq "1" ] && [ -z "$1" ]; then
exec $MOZ_CLIENT_PROGRAM "xfeDoCommand(openBrowser)" 2>/dev/null >/dev/null
fi

# if there's no command line argument and there's not a running
# instance then just fire up a new copy of the browser
if [ -z "$1" ]; then
exec $MOZ_PROGRAM 2>/dev/null >/dev/null
fi

unset RETURN_VAL

# If there's a command line argument but it doesn't begin with a -
# it's probably a url. Try to send it to a running instance.

USE_EXIST=1
opt="$1"

if [ "${USE_EXIST}" -eq "1" ] && [ "${ALREADY_RUNNING}" -eq "1" ]; then
# check to make sure that the command contains at least a :/ in it.
echo $opt | grep -e ':/' 2>/dev/null > /dev/null
RETURN_VAL=$?
if [ "$RETURN_VAL" -eq "1" ]; then
# if it doesn't begin with a '/' and it exists when the pwd is
# prepended to it then append the full path
echo $opt | grep -e '^/' 2>/dev/null > /dev/null
if [ "${RETURN_VAL}" -ne "0" ] && [ -e `pwd`/$opt ]; then
opt="`pwd`/$opt"
fi
exec $MOZ_CLIENT_PROGRAM "openurl($opt)" 2>/dev/null >/dev/null
fi
# just pass it off if it looks like a url
exec $MOZ_CLIENT_PROGRAM "openurl($opt,new-window)" 2>/dev/null >/dev/null
fi

exec $MOZ_PROGRAM ${1+"$@"}

Last edited by SADANA; 06-20-2004 at 04:26 PM.
 
Old 07-07-2004, 04:06 PM   #4
warren1715
LQ Newbie
 
Registered: Mar 2004
Location: Louisiana
Distribution: Mandrake 10
Posts: 8

Rep: Reputation: 0
firefox - new window

I wrote this to solve that problem. I start firefox-agent instead of firefox for all browser applications. You may need to make slight changes to match your system

--UPDATED for version 0.9.1--

#!/bin/sh
#
# Script name: /usr/bin/firefox-agent
# Launches firefox in a new window (or tab)
# Written by *****. License 'GPL'
#
# Tested on firefox 0.9.1 using mandrake 10.0
#
PIDOF='/sbin/pidof' # Location of 'pidof' program
DIST_BIN='/usr/local/firefox' # where firefox is installed
WINDOWTYPE='new-window' # Use 'new-window' or 'new-tab', your preference
#
# You should not need to change below.
#
PREFS="${HOME}/.mozilla/firefox/`ls ${HOME}/.mozilla/firefox | grep default | sed -e 's/\///g'`/prefs.js"
MOZ_CLIENT_PROGRAM=$DIST_BIN/mozilla-xremote-client
BROWSER='firefox-bin'
HOMEURL=`cat $PREFS | grep -e \"browser.startup.homepage\" | sed -e 's/\(.*\,\ \"\)\(.*\)\(\".*\)/\2/g'`
#
if test "`$PIDOF $BROWSER`" = "" ; then
exec $DIST_BIN/firefox "$1"
else
if test "$1" = "" ; then
exec $MOZ_CLIENT_PROGRAM -a firefox "openURL("$HOMEURL",$WINDOWTYPE)"
else
exec $MOZ_CLIENT_PROGRAM -a firefox "openURL("$1",$WINDOWTYPE)"
fi
fi

Last edited by warren1715; 07-07-2004 at 06:08 PM.
 
Old 07-08-2004, 12:20 AM   #5
Cerbere
Member
 
Registered: Dec 2002
Location: California
Distribution: Slackware & LFS
Posts: 799

Rep: Reputation: 33
Why the script? Is hitting 'ctrl+n' too difficult?

Enjoy!
--- Cerbere
 
Old 07-08-2004, 12:50 PM   #6
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
Some applications such as e-mail clients need a way to pass urls to the browser - hence the reason for the script. Personally I just use crtl+n or ctrl+t when browsing normally though.
 
Old 07-11-2004, 05:21 PM   #7
slaw219
LQ Newbie
 
Registered: Jul 2004
Distribution: Suse 9.1 Professional
Posts: 7

Rep: Reputation: 0
I'm trying to use this shell-script, but have no idea how to create it or use it. Could somebody explain how I use this script or where to find info on creating scripts?
Thanks
 
Old 07-11-2004, 07:16 PM   #8
webazoid
Member
 
Registered: Jun 2004
Posts: 224

Rep: Reputation: 30
Re: firefox - new window

Quote:
Originally posted by warren1715
I wrote this to solve that problem. I start firefox-agent instead of firefox for all browser applications. You may need to make slight changes to match your system

--UPDATED for version 0.9.1--

#!/bin/sh
#
# Script name: /usr/bin/firefox-agent
# Launches firefox in a new window (or tab)
# Written by *****. License 'GPL'
#
# Tested on firefox 0.9.1 using mandrake 10.0
#
PIDOF='/sbin/pidof' # Location of 'pidof' program
DIST_BIN='/usr/local/firefox' # where firefox is installed
WINDOWTYPE='new-window' # Use 'new-window' or 'new-tab', your preference
#
# You should not need to change below.
#
PREFS="${HOME}/.mozilla/firefox/`ls ${HOME}/.mozilla/firefox | grep default | sed -e 's/\///g'`/prefs.js"
MOZ_CLIENT_PROGRAM=$DIST_BIN/mozilla-xremote-client
BROWSER='firefox-bin'
HOMEURL=`cat $PREFS | grep -e \"browser.startup.homepage\" | sed -e 's/\(.*\,\ \"\)\(.*\)\(\".*\)/\2/g'`
#
if test "`$PIDOF $BROWSER`" = "" ; then
exec $DIST_BIN/firefox "$1"
else
if test "$1" = "" ; then
exec $MOZ_CLIENT_PROGRAM -a firefox "openURL("$HOMEURL",$WINDOWTYPE)"
else
exec $MOZ_CLIENT_PROGRAM -a firefox "openURL("$1",$WINDOWTYPE)"
fi
fi
what's firefox agent?
 
Old 07-11-2004, 07:21 PM   #9
webazoid
Member
 
Registered: Jun 2004
Posts: 224

Rep: Reputation: 30
i need help w/ running the script too!
 
Old 07-11-2004, 08:52 PM   #10
slaw219
LQ Newbie
 
Registered: Jul 2004
Distribution: Suse 9.1 Professional
Posts: 7

Rep: Reputation: 0
he simply made a script called firefox-agent and linked all his launchers to firefox-agent instead of firefox

I think I know how to make scripts work now...however when I tried to make this file it didn't work..nothing opens. It will open the first instance but won't open a second...here's my code I have my firefox installed in /opt/firefox/

Code:
cript name: /usr/bin/firefox-agent
 # Launches firefox in a new window (or tab)
 # Written by *****. License 'GPL'
 #
 # Tested on firefox 0.9.1 using mandrake 10.0
 #
 PIDOF='/sbin/pidof' # Location of 'pidof' program
 DIST_BIN='/opt/firefox' # where firefox is installed
 WINDOWTYPE='new-tab' # Use 'new-window' or 'new-tab', your preference
 #
 # You should not need to change below.
 #
 PREFS="${HOME}/.mozilla/firefox/`ls ${HOME}/.mozilla/firefox | grep default | sed -e 's/\///g'`/prefs.js"
 MOZ_CLIENT_PROGRAM=$DIST_BIN/mozilla-xremote-client
 BROWSER='firefox-bin'
 HOMEURL=`cat $PREFS | grep -e \"browser.startup.homepage\" | sed -e 's/\(.*\,\ \"\)\(.*\)\(\".*\)/\2/g'`
 #
 if test "`$PIDOF $BROWSER`" = "" ; then
 exec $DIST_BIN/firefox "$1"
 else
 if test "$1" = "" ; then
 exec $MOZ_CLIENT_PROGRAM -a firefox "openURL("$HOMEURL",$WINDOWTYPE)"
 else
 exec $MOZ_CLIENT_PROGRAM -a firefox "openURL("$1",$WINDOWTYPE)"
 fi
 fi


Thanks =/

Last edited by slaw219; 07-11-2004 at 08:59 PM.
 
Old 07-11-2004, 11:52 PM   #11
p-static
Member
 
Registered: Jul 2004
Distribution: Gentoo
Posts: 101

Rep: Reputation: 15
Actually, the latest firefox doesn't seem to have problems with multiple windows open, thus making all of this kind of pointless.
 
Old 07-12-2004, 04:19 AM   #12
BluePyre
Member
 
Registered: Mar 2004
Location: London
Distribution: Mandrake 10
Posts: 172

Rep: Reputation: 30
To make a new script:
Save the script into a new text file. Call it whatever you like, with whatever extension, it makes no difference.
From a terminal, type:

chmod a+x scriptFileName

and then to run the script, a simple

./scriptFileName

Obviously replace scriptFileName with the name of your script
 
Old 07-13-2004, 10:24 PM   #13
warren1715
LQ Newbie
 
Registered: Mar 2004
Location: Louisiana
Distribution: Mandrake 10
Posts: 8

Rep: Reputation: 0
I wrote this because I got tired of clicking on links from other applications (such as email) while the browser was already open and getting that dreaded profile manager (^N can't do that). The post above does not work with version 0.8, please check your version. I have another script version for 0.8 if you want. To make the script work, copy to a text editor and save the file as firefox-agent in a directory in your path (you may have to log on as root). Change the properties of the saved file and make it executable. Edit the file to match your system (pidof and firefox locations must be correct). To test run firefox-agent. To use the script, associate URL's with firefox-agent.

0.8 version:

#!/bin/sh
#
# Script name: /usr/bin/firefox-agent
# Launches firefox in a new window (or tab)
# Written by *****. License 'GPL'
#
# Tested on FireFox 0.8 using mandrake 10.0
#
PIDOF='/sbin/pidof' # Location of 'pidof' program
DEFAULTBROWSER='/usr/local/firefox/firefox' # Locaion of firefox
WINDOWTYPE='new-window' # Use 'new-window' or 'new-tab', your preference
#
# You should not need to change below.
#
BROWSER='firefox-bin'
PREFS="${HOME}/.phoenix/default/`ls ${HOME}/.phoenix/default`/prefs.js"
HOMEURL=`cat $PREFS | grep -e \"browser.startup.homepage\" | sed -e 's/\(.*\,\ \"\)\(.*\)\(\".*\)/\2/g'`
#
if test "`$PIDOF $BROWSER`" = "" ; then
exec $DEFAULTBROWSER "$1"
else
if test "$1" = "" ; then
exec $DEFAULTBROWSER -remote openURL"("$HOMEURL",$WINDOWTYPE)"
else
exec $DEFAULTBROWSER -remote openURL"("$1",$WINDOWTYPE)"
fi
fi

Last edited by warren1715; 07-13-2004 at 10:32 PM.
 
Old 07-14-2004, 12:18 AM   #14
slaw219
LQ Newbie
 
Registered: Jul 2004
Distribution: Suse 9.1 Professional
Posts: 7

Rep: Reputation: 0
I'm looking for the 9.1 script...9.2 has been out for a while but it still says 9.1 for linux. I may just have to deal with it..or make my own, but that seems a lot more complicated than I'm willing to commit
 
Old 07-14-2004, 01:06 AM   #15
webazoid
Member
 
Registered: Jun 2004
Posts: 224

Rep: Reputation: 30
a recent nightly build of the ff trunk doesn't have that problem anymore.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
firefox- open html in new window kpachopoulos Linux - Software 1 08-14-2005 04:08 AM
open a new window from Firefox lordofring Linux - Software 4 04-18-2005 06:03 PM
firefox won't open links in new window lukameen Slackware 13 03-15-2005 07:14 AM
Mozilla (official) Open New Window script tuxq Linux - Software 1 08-10-2004 07:43 PM
Open a new Mozilla window linuxnube Linux - Software 3 05-17-2004 11:33 PM


All times are GMT -5. The time now is 11:00 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration