19

On of the first things I do when first using a fresh Firefox profile, is to set browser.urlbar.trimURLs to false (which really should be changeable though ‘Preferences’ or should have remained default), and to change the search and homepage defaults to DuckDuckGo. Currently I manually go to about:config, click through the angry warning message, and search for the keys (which unlike in DConf Editor, aren't even organised).

So I would like to know how to read and write these keys from the command-line so that I can add these tweaks to my customisations script.

12

[This doesn't provide what you've asked for but is a different way to achieve the same result.]

First, about the warning... You can make sure you never see it again (on a per profile basis) as shown below:

enter image description here

Now, as regards the preferences you desire. In general, you can create a simple text file called user.js. This file has to be placed in the relevant profile folder such as /home/username/.mozilla/firefox/random.default (where random is something unique to each user).

The structure and syntax of user.js is described in User.js file for example.

So in your case, you would have a line such as:

user_pref("set browser.urlbar.trimURLs","false");  

or, to use your other example (but see further down):

user_pref("browser.search.defaulturl","https://duckduckgo.com/");

However, I suggest that you first ensure that the preferences you set are valid for the browser version you're using. I say this because I don't see browser.search.defaulturl at all in my about:config. I'm using Firefox 22 beta. Instead, I see:

browser.search.defaultenginename;Google

Engine

So, taking the example of using Bing instead of Google, the other line in your user.js if you're using Firefox 22, would be:

user_pref("browser.search.defaultenginename","Bing");

As the image indicates, you can search for additional engines.

So, in short, you can put your preferences in user.js and you can remove the nag screen by unticking in the first image.

Also, as indicated in the resource I linked to, you must restart the browser for the code in user.js to take effect.

6

Here is a possible shell script. You have to cd to your profile directory before using it (where the user.js is). Say the script is called ff_set you could call it like:

ff_set browser.search.defaulturl '"https://duckduckgo.com/"'

Here is the code:

#!/bin/bash

sed -i 's/user_pref("'$1'",.*);/user_pref("'$1'",'$2');/' user.js
grep -q $1 user.js || echo "user_pref(\"$1\",$2);" >> user.js

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.