[SOLVED] changing home page url for firefox using script
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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).
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.
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?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.