Customizing Firefox - Default Preference Files

IMPORTANT: defaults/pref no longer works as a location for default preference files. You should use default/preferences. (You will have to create this directory.) See this post.

One of the most talked about subjects on the Enterprise Working Group Mailing List is customizing Firefox. There are quite a few different methods that people are using today, and there are more that people don't know about.

I'm going to do a series where I go over each method (that I know about) and detail how it works and what it can change. This should allow people that are customizing Firefox to make more informed choices about which method to use.

The first method we're going to talk about is adding default preference files.

If you go to the URL bar in your browser and type about:config, you'll see all of the various preferences that have been set in your browser. You'll notice that some of them are bold and some are not. You'll also notice that for the bold ones, it says "user set" in the Status column. These are the preferences that have been customized in your browser. The rest of the settings are marked "default" and are the default settings for the browser. (If you have some locked preferences, the status will say "Locked" and the preference will be in italics. We'll talk more about those in a later post.)

All of these preferences are stored in JavaScript files. Your customized settings are stored in a file called prefs.js in your profile directory. The default preferences are stored in various files like all.js or firefox.js. It is not recommended that you modify these files directly (and you can't easily, because they are stored in the file omni.ja[r]). You can, however, create your own Javascript files and place them in a location so that Firefox reads them as default preferences. That location is the defaults/preferences directory in the same location where the Firefox executable is placed. Files in this location will be used for all Firefox users (they are not profile specific).

Adding default preferences is as simple as creating a file with the extension of .js in the defaults/preferences directory and adding lines like:

pref("browser.rights.3.shown", true);

It's important that you get the format right based on the preference type. In this case, the preference is a boolean, so we specify true or false without quotes as the value on the right. If it is a string, you put it in quotes. If it is an integer, you put the value without quotes. You can tell the type of the preference by looking at the Type column in about:config.

In this example, we're setting a boolean value that tells Firefox that the rights notification has already been shown. This is the notification when you first run Firefox that says "Mozilla Firefox is free and open source software..."

All you can do with the default preferences file is set the default value of preferences. You cannot lock them and you cannot override user set preferences. (There's a bug open for locking via a default preferences file.) There are also preferences you can't set at all via this mechanism, like browser.startup.homepage. This preference is a complex preference and uses a different mechanism. We'll be talking about other methods can set this preference.

So using a default preference file is good if all you want to change is the default value for a few preferences. It doesn't let you lock preferences and it doesn't let you change the homepage.

14 Responses to “Customizing Firefox - Default Preference Files”

  1. Jay Hilliard March 15, 2012 at 1:02 pm #

    Thanks for starting this list. This is useful information and I'm glad someone is tracking the Enterprise product this way.
    I have one question, what if I want to change the defaults within firefox itself (perhaps in firefox/defaults/pref/, so I don't have to tweak user profiles? Would .js files and be honored for all users who run Firefox on this system?

    • Mike Kaply March 15, 2012 at 1:54 pm #

      The changes I've indicated in this post are definitely changes to firefox/defaults/pref and they will be honored for all users that run that version of Firefox.

      Most of the changes we'll be talking about in this series will apply to the installed Firefox, so they will happen to all users on the system (Or you can bundle the changes with a Firefox that you are distributing.)

  2. Steve Trout August 21, 2012 at 8:25 am #

    Hi Mike,

    Sorry to ask probably a newbie question - I am trying to set a default homepage for every firefox user and then allow them to change that if they like.

    To do so I have used local-settings.js and mozilla.cfg and used either a lockPref("browser.startup.homepage", "www.bbc.co.uk"); or a pref("browser.startup.homepage", "www.bbc.co.uk"); in mozilla.cfg to set the default. I have also tried defaultPref() but get the same results as commented yesterday by Stefan in https://bugzilla.mozilla.org/show_bug.cgi?id=775937.

    I am then trying to use a user.js to overwrite the setting defined for browser.startup.homepage on mozilla.cfg. I know my user.js works as I am able to change other settings but I can't change the browser.startup.homepage if it has been set by mozilla.cfg regardless if I use pref() or lockPref().

    Hope this makes sense and any help you can provide would be welcomed.

    Thanks in advance,

    Steve

    • Mike Kaply August 21, 2012 at 8:43 am #

      The homepage must be a URL - http://www.bbc.co.uk

      What you want is a default pref, but to do a default pref, it can get weird. Use:

      defaultPref("browser.startup.homepage", "data:text/plain,browser.startup.homepage=http://www.bbc.co.uk");

      and it should work.

      All this should work via CFG files.

      • Steve Trout August 21, 2012 at 9:00 am #

        Thanks Mike,

        Worked a treat!! Solved my problems. I have found your articles an excellent ready - keep them up.

        Steve

  3. Robert February 11, 2013 at 9:22 am #

    I cannot get the lockpref to work. RH6.3, Firefox 18.

    I created mozilla.cfg at:
    /usr/lib64/firefox
    It contains two lines:
    //
    lockpref ("security.enable_ssl3", true);

    I created local-settings at:
    /usr/lib64/firefox/default/preferences

    It contains two lines:
    pref("general.config.obscure_value", 0);
    pref("general.config.filename", "mozilla.cfg");

    When I goto about:config, it still shows security.enable_ssl3 false.

    any ideas???

    • Mike Kaply February 11, 2013 at 11:58 pm #

      It should be lockPref

      not lockpref...

  4. Appu March 13, 2013 at 9:24 am #

    Hello,

    I work as a System administrator in an international company.
    We wish to push some bookmark on users Firefox (15.0.1 for most of them).
    I look for a help everywhere but no way to do it.

    Can you please give me some tips ?

  5. Jake April 24, 2013 at 4:33 pm #

    Sweet site. i used your instructions and http://www.mockbox.net/configmgr-sccm/174-install-and-configure-firefox-silently to deploy our company's Firefox. However, I was wondering if you knew the about:config pref syntax for enabling the bookmark toolbar on first user start-up (dubbed "PersonalToolbar" i presume...)
    Thanks.

Trackbacks/Pingbacks:

  1. Customizing Firefox – Autoconfig Files | Mikes Musings - March 16, 2012

    [...] is not required. In order to use a config file, you have to specify that you want to use one in a default preferences file. It looks like [...]

  2. Don't Unpack and Repack omni.ja[r] | Mikes Musings - May 6, 2013

    [...] wrong. Any modifications you need to make to Firefox, whether it be changing the default profiles, changing the default preferences or even overriding specific files can be done WITHOUT repackaging [...]

  3. Customizing Firefox - Autoconfig Files (Continued) | Mikes Musings - May 15, 2013

    [...] value) sets the user value of a preference. If you remember in our first post, I went over the difference between user prefs and default prefs. This function explicitly sets the [...]

Leave a Reply:

Gravatar Image