LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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-22-2004, 08:24 PM   #1
DiscoGranny
LQ Newbie
 
Registered: Jun 2004
Posts: 12

Rep: Reputation: 0
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
 
Old 06-22-2004, 09:15 PM   #2
Axion
Member
 
Registered: Jan 2003
Location: Albany, NY
Distribution: Slackware 9.1, Gentoo 2004.1
Posts: 153

Rep: Reputation: 30
all i could find was this, did you see it?

http://www.deftone.com/blogzilla/arc...n_new_tab.html
 
Old 06-22-2004, 11:02 PM   #3
DiscoGranny
LQ Newbie
 
Registered: Jun 2004
Posts: 12

Original Poster
Rep: Reputation: 0
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
 
Old 06-22-2004, 11:23 PM   #4
DiscoGranny
LQ Newbie
 
Registered: Jun 2004
Posts: 12

Original Poster
Rep: Reputation: 0
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
 
Old 06-22-2004, 11:50 PM   #5
Axion
Member
 
Registered: Jan 2003
Location: Albany, NY
Distribution: Slackware 9.1, Gentoo 2004.1
Posts: 153

Rep: Reputation: 30
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
 
Old 06-23-2004, 12:54 AM   #6
DiscoGranny
LQ Newbie
 
Registered: Jun 2004
Posts: 12

Original Poster
Rep: Reputation: 0
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-23-2004 at 12:55 AM.
 
Old 06-24-2004, 03:30 AM   #7
Axion
Member
 
Registered: Jan 2003
Location: Albany, NY
Distribution: Slackware 9.1, Gentoo 2004.1
Posts: 153

Rep: Reputation: 30
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...
 
Old 07-19-2004, 03:33 PM   #8
calt129
LQ Newbie
 
Registered: Jun 2004
Posts: 1

Rep: Reputation: 0
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
 
  


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 URL editing davidleroux1 Linux - Newbie 3 04-24-2005 04:43 AM
firefox homepage hijacked?? pinkfloyd Linux - Security 2 01-31-2005 05:58 PM
how is cache stored in mozilla? gajaykrishnan Programming 2 08-13-2004 10:02 AM
Firefox homepage problems remz Linux - Software 2 07-25-2004 10:56 PM
where is mozilla favourites files stored? karfei00 Linux - Newbie 2 06-14-2004 10:54 PM


All times are GMT -5. The time now is 04:16 PM.

Main Menu
Advertisement
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