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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
06-22-2004, 07:24 PM
|
#1
|
|
LQ Newbie
Registered: Jun 2004
Posts: 12
Rep:
|
Where/How is Homepage URL stored in Mozilla Firefox 0.9?
Okay, I worked up a nice little script to circumvent the profiles hassle when trying to run multiple instances of firefox 0.9.
My script does one of these four things:
If firefox isn't running at all and a URL isn't supplied, launch a new instance
If firefox isn't running at all and a URL is supplied, launch a new instance that opens the URL
If firefox is running and a URL is supplied, open URL in a new tab
If firefox is running and a URL isn't supplied, open a new tab that's blank
the last condition is the tricky one. I don't want it to open blank. I would rather have it open up the home page. I have scoured the 'net and can't find the command that will accomplish this or the location (either file or variable) that stores what the homepage URL is. Any help?
*Note: for the homepage, I tried $home. This doesn't work. Just remove it (be sure to leave the comma), if you just want it to open blank.*
Code:
#!/bin/sh
# Works for Firefox 0.9
# Written by Robert Mullenix, June 2004
MOZILLA="/usr/share/firefox/firefox"
# Find out Firefox is open already
if $MOZILLA -a firefox -remote "ping()" 2>/dev/null
then
if [ -z $1 ]
then
# instance already opened, open new tab
$MOZILLA -a firefox -remote "openURL($home,new-tab)" &
else
# instance already opened, launch URL $1 in new tab
$MOZILLA -a firefox -remote "openURL($1,new-tab)" &
fi
else
if [ -z $1 ]
then
# no URL present, just open firefox
$MOZILLA &
else
# no instances exist, open a new window with URL $1
$MOZILLA $1 &
fi
fi
exit 1
|
|
|
|
06-22-2004, 08:15 PM
|
#2
|
|
Member
Registered: Jan 2003
Location: Albany, NY
Distribution: Slackware 9.1, Gentoo 2004.1
Posts: 153
Rep:
|
|
|
|
|
06-22-2004, 10:02 PM
|
#3
|
|
LQ Newbie
Registered: Jun 2004
Posts: 12
Original Poster
Rep:
|
I missed that. It's a good link and it works for mozilla, but it won't work for firefox. I extracted the comm.jar in firefox/chrome and then went into the content directory, but right away you'll notice that there is no navigator folder or navigator.js.
Whatever causes mozilla to open up a new tab isn't there...
good idea, though
|
|
|
|
06-22-2004, 10:23 PM
|
#4
|
|
LQ Newbie
Registered: Jun 2004
Posts: 12
Original Poster
Rep:
|
Okay, I did some snooping to try and figure out where Firefox puts the homepage. It stores it in ~/.mozilla/firefox/{profile_name}.ima/prefs.js
Since I use the default profile, I did some scripting and came up with this. It may not work for everyone, but it works for me:
Code:
#!/bin/sh
# firefox.sh
# Works for Firefox 0.9
# Written by Robert Mullenix, June 2004
HOMEPAGE=`cat ~/.mozilla/firefox/default.ima/prefs.js | grep browser.startup.homepage\" | cut -f 4 -d \"`
MOZILLA="/usr/share/firefox/firefox"
# Find out Firefox is open already
if $MOZILLA -a firefox -remote "ping()" 2>/dev/null
then
if [ -z $1 ]
then
# instance already opened, open new tab
$MOZILLA -a firefox -remote "openURL($HOMEPAGE,new-tab)" &
else
# instance already opened, launch URL $1 in new tab
$MOZILLA -a firefox -remote "openURL($1,new-tab)" &
fi
else
if [ -z $1 ]
then
# no URL present, just open firefox
$MOZILLA &
else
# no instances exist, open a new window with URL $1
$MOZILLA $1 &
fi
fi
exit 1
|
|
|
|
06-22-2004, 10:50 PM
|
#5
|
|
Member
Registered: Jan 2003
Location: Albany, NY
Distribution: Slackware 9.1, Gentoo 2004.1
Posts: 153
Rep:
|
You're right, it won't work for everyone because the "default.ima" folder is random. For instance, here it is named "default.6ss". Would be nice if you could have the script guess the ending
|
|
|
|
06-22-2004, 11:54 PM
|
#6
|
|
LQ Newbie
Registered: Jun 2004
Posts: 12
Original Poster
Rep:
|
This'll do the trick:
I have really gotten to like the grep cut combo, but it seems a little clunky...
Modifications in bold
Code:
# firefox.sh
# Works for Firefox 0.9
# Written by Robert Mullenix, June 2004
PROFILEPATH=`cat ~/.mozilla/firefox/profiles.ini | grep Path | cut -f 2 -d =`
HOMEPAGE=`cat ~/.mozilla/firefox/$PROFILEPATH/prefs.js | grep browser.startup.homepage\" | cut -f
MOZILLA="/usr/share/firefox/firefox"
# Find out Firefox is open already
if $MOZILLA -a firefox -remote "ping()" 2>/dev/null
then
if [ -z $1 ]
then
# instance already opened, open new tab
$MOZILLA -a firefox -remote "openURL($HOMEPAGE,new-tab)" &
else
# instance already opened, launch URL $1 in new tab
$MOZILLA -a firefox -remote "openURL($1,new-tab)" &
fi
else
if [ -z $1 ]
then
# no URL present, just open firefox
$MOZILLA &
else
# no instances exist, open a new window with URL $1
$MOZILLA $1 &
fi
fi
exit 1
Last edited by DiscoGranny; 06-22-2004 at 11:55 PM.
|
|
|
|
06-24-2004, 02:30 AM
|
#7
|
|
Member
Registered: Jan 2003
Location: Albany, NY
Distribution: Slackware 9.1, Gentoo 2004.1
Posts: 153
Rep:
|
Odd, the last script does not work. the grep by itself works and extracts default.6ss from the ini file, but the full path to the prefs file is missing the $PROFILEPATH subdir...the script thinks my prefs.js file is located at "/home/axion/.mozilla/firefox//prefs.js"...default6ss is not added for some reason, though the same grep works outside of the script...
|
|
|
|
07-19-2004, 02:33 PM
|
#8
|
|
LQ Newbie
Registered: Jun 2004
Posts: 1
Rep:
|
a tiny improvement
This should work for you, it may be inefficient (2 cut's :P) but it works
Code:
# firefox.sh
# Works for Firefox 0.9
# Written by Robert Mullenix, June 2004
# Modified by Cuneyt Yilmaz, June 2004
PROFILEPATH=`cat ~/.mozilla/firefox/profiles.ini | grep Path | cut -f 2 -d =`
HOMEPAGE=`cat ~/.mozilla/firefox/$PROFILEPATH/prefs.js | grep browser.startup.homepage\" | cut -f 2 -d , | cut -f 2 -d \"`
# I'm using the following, but hard-coded path may be better for some
#MOZILLA=`which firefox`
MOZILLA=/usr/local/firefox/firefox
URL=$1
# if no URL is given, use the home page
if [ -z $URL ]; then
URL=$HOMEPAGE
fi
$MOZILLA -a firefox -remote "ping()" 2>/dev/null
if [ $? -eq 0 ]; then
# it's already running
$MOZILLA -a firefox -remote "openURL($URL,new-tab)" &
else
# not running
$MOZILLA "$URL" &
fi
exit 1
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 02:15 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|