LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-15-2010, 12:00 PM   #1
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Rep: Reputation: 49
changing home page url for firefox using script


My Debian Lenny's Firefox prefs.js file looks like this:

kushalk@debian:~$ cat .mozilla/firefox/htk03tiv.default/prefs.js

Code:
user_pref("app.update.lastUpdateTime.addon-background-update-timer", 1268425047);
user_pref("app.update.lastUpdateTime.background-update-timer", 1268425047);
user_pref("app.update.lastUpdateTime.blocklist-background-update-timer", 1268425047);
user_pref("app.update.lastUpdateTime.microsummary-generator-update-timer", 1268252135);
user_pref("app.update.lastUpdateTime.search-engine-update-timer", 1268425047);
user_pref("browser.migration.version", 1);
user_pref("browser.places.importBookmarksHTML", false);
user_pref("browser.places.importDefaults", false);
user_pref("browser.places.leftPaneFolderId", -1);
user_pref("browser.places.migratePostDataAnnotations", false);
user_pref("browser.places.smartBookmarksVersion", 1);
user_pref("browser.places.updateRecentTagsUri", false);
user_pref("browser.rights.3.shown", true);
user_pref("browser.startup.homepage", "http://www.abc.com");
user_pref("browser.startup.homepage_override.mstone", "rv:1.9.0.18");
user_pref("extensions.enabledItems", "{972ce4c6-7e08-4474-a285-3208198ce6fd}:3.0.6");
user_pref("extensions.lastAppVersion", "3.0.6");
user_pref("intl.charsetmenu.browser.cache", "ISO-8859-1, UTF-8");
user_pref("network.cookie.prefsMigrated", true);
user_pref("spellchecker.dictionary", "en_US");
user_pref("urlclassifier.keyupdatetime.https://sb-ssl.google.com/safebrowsing/newkey", 1270236515);
Now I am trying to set the home page i.e. browser.startup.homepage variable (in red color) with my own URL using a script. Here is what I am trying to do but it is not working:

Code:
sed -r 's/*.browser.startup.homepage.*$/user_pref("browser.startup.homepage", "http://example.com");/' .mozilla/firefox/$profile/prefs.js >
prefs.js.temp
Note that the in the original file (prefs.js), the URL could be set to *anything* and not necessarily www.abc.com. So I need to search for the variable user_pref("browser.startup.homepage" and then set the entire line with my own supplied line (with the desired URL).

Thanks
 
Old 03-15-2010, 12:25 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Not tested:

Code:
sed '/startup\.homepage/s/"http:[^"]/"http:\/\/my\.own\.url"/' oldfile > newfile
Note that:
1. Literal "." needs to be escaped
2. If "/" is the sed s delimiter, then literal "/" needs to be escaped.
3. I **think** literal double-quotes are OK inside single qoutes, but you need to test to be sure.
4. If you want the replacement to be the content of a variable, Then the whole sed command string needs to be in double-quotes. In this event, the other double-qouotes will definitely need to be escaped.
 
Old 03-15-2010, 12:27 PM   #3
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
Why not create a user.js file in the profile directory with the one line in it.

user_pref("browser.startup.homepage", "http://www.abc.com");

https://developer.mozilla.org/En/A_B...ng_preferences
 
Old 03-15-2010, 12:34 PM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Are you changing prefs.js when FF is running or not? FF dumps its current configuration into prefs.js when it closes.

When you write "it is not working", do you mean your script is not changing the line or that it does change the line (in which case it does not matter whether your script it or edit it manually) but when you next start FF the home page is not changed?
 
Old 03-15-2010, 12:36 PM   #5
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Original Poster
Rep: Reputation: 49
Quote:
Originally Posted by smoker View Post
Yes that's a good solution too. I didn't know about user.js until now... Thanks smoker...
 
  


Reply



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
Tricky: Script to remove Dublets URL links into an HTML page? frenchn00b Programming 4 05-25-2009 05:20 AM
Changing home page in firefox. User Name. Linux - Newbie 2 08-18-2006 07:05 PM
Please help; firefox home page hijacked tannranger Linux - Software 2 06-29-2006 04:12 PM
Ksmoothdock 3.5.1 sets home page on Firefox 1.0.7 Mr_Jones Linux - Software 3 03-09-2006 11:16 PM
disable changing default home page tmz1 Linux - General 4 10-01-2003 03:44 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:38 AM.

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
Open Source Consulting | Domain Registration