Customizing Firefox - Default Profiles

Update: I have made major modifications to this post. I was not aware that Firefox copied the contents of the defaults/profile directory on the file system after using the files on omni.ja(r).

This next method of customization is not as widely used, but it is still worth mentioning. It involves changing the files that Firefox uses when creating a new profile. We'll also take this opportunity to talk about userContent.css and userChrome.css which we mentioned earlier.

When you create a new profile in Firefox, the profile is prepopulated from the directory defaults/profile in the file omni.ja(r) as well as the contents of the defaults/profile directory where Firefox is installed. The contents of the defaults/profile directory are copied over after the files in omni.ja(r). To retrieve the files you want to modify, unzip the file omni.ja(r) which is located in the Firefox directory. It's just a zip file renamed. Make sure you unzip it into a temporary directory. You'll see the following files in the defaults/profile directory:

bookmarks.html
chrome/userChrome-example.css
chrome/userContent-example.css
localstore.rdf
mimeTypes.rdf
prefs.js

Copy the files you want to modify into the directory defaults/profile underneath where the Firefox executable is located (you'll have to create this directory). When a new profile is created, these files (and any other files that are also in the directory) are copied over. You have a two choices when it comes to modifying the default profile - changing the existing files or adding your own.

If you add additional files into this directory, those files are copied into the default profile along with the rest of the files. This is most commonly used if you want to have default certificate databases. I've seen cases where someone started Firefox, added the certificates and certificates authorities they needed and then copied the various *.db profiles from their profile and put them in the default profile so all their users would get them.

The other thing you can do is modify the existing files.

You can modify bookmarks.html to add or remove bookmarks. The file has a somewhat unique format, but it's pretty straightforward to change.

You can modify prefs.js to set default preferences for a user. Here's an example of setting a preference in prefs.js:

user_pref("browser.startup.homepage", "http://mike.kaply.com");

You can overwrite localstore.rdf if you want to customize the browser. localstore.rdf stores things like the size of the browser, whether or not certain toolbars are displayed and more. You can make customizations in your browser and then copy the localstore.rdf from your profile into the default profile.

But by far the most interesting files in the default profile are userChrome-example.css and userContent-examples.css. When these files are present in your profile using their correct names - userChrome.css and userContent.css - they can be used to override just about anything on web pages and in the browser.

userChrome.css allows you to modify the chrome of Firefox. That's the area around the browser window. So for instance, if you wanted all menuitems to be bigger, you could specify:

menu, menuitem {
  font-size: 32px !important;
}

There are so many things you can do with this file, I couldn't even begin to describe them here. You can hide menuitems, change parts of the UI, etc. If you choose to hide something, it's better to use visibility: collapse than display: none. Messing with display can cause very strange results in Firefox. If you're interested in figuring out the IDs of the various elements of the UI, check out the DOM Inspector. You can also just browser through the source code. browser-menubar.inc and browser-context.inc are particularly useful.

userContent.css allows you to customize the content of web pages. There are even ways to make your styles only apply to certain web pages. There's a ton of information about userChrome.css on the web, so I can't really do it justice in this post. I just want to make sure you are aware of it.

If you do choose to use userContent.css or userChrome.css, I would suggest the methods I talked about in my earlier post on autoconfig. Then you don't have to mess with the default profile.

Modifying the default profile can be a handy way to set some defaults for your user, but remember that these files are only used when a new profile is created.

18 Responses to “Customizing Firefox - Default Profiles”

  1. Tyler Riti March 30, 2012 at 11:47 am #

    I didn't know about the omni.jar file. To set a default browser window size, I've always just copied a localstore.rdf file into the defaults/profile directory at the same level as the firefox binary (/Applications/Firefox.app/Contents/MacOS/defaults/profile on OS X), creating the directories as needed.

  2. pd March 31, 2012 at 7:24 am #

    Michael I've not followed these customize Firefox posts closely but it appears there's been roughly half a dozen of them so far, all covering different, sometimes perhaps relatively obscure, ways to customize Firefox. Whilst this is great for documentation and immediate assistance purposes, does it not also highlight a very chunky hole in Firefox's corporate deployment customizability? How many of your tips are available through the CCK? Shouldn't they all be if they are not? Well, if not the CCK, then a new one-stop customization tool of another name with a new marketing focus? It appears that your posts - whilst very helpful I'm sure - really just add weight to the aggravation expressed by users that generated the deployment of the ESR release, yet no followup seems to have been made with the client deployment issues that were raised except your posts. I sense a tool is necessary! How about looking at combining the CCK, Mozilla Profile Manager and all the tips and tricks you've outlined, into one Firefox Deployment Kit (to coin a name) ?

    • Mike Kaply March 31, 2012 at 7:36 pm #

      You're stealing my thunder.

      My last post is going to be about how the CCK fixes everything :)

      Seriously, you're absolutely correct.

      What's really needed here is what Netscape used to produce - the Mission Control Desktop.

      • pd March 31, 2012 at 8:43 pm #

        Sorry about that :)

        Look forward to reading your posts.

        Never heard of the Mission Control Desktop. Sounds very interesting. I hope something emerges because all I saw at the time of the kerfuffle from corporates about deployment was some bug traffic about Microsoft Installer (msi) binaries. That may well be a useful option but I doubt it covers everything that you've outlined.

  3. Marc May 8, 2012 at 8:24 am #

    I tried to add certificates by copying a cert8.db file to defaults/profile in Thunderbird 10, but it does not work.

    Is there any hint what may be wrong?

    • Mike Kaply May 8, 2012 at 8:26 am #

      I would start by putting a test file in the directory and making sure it gets copied over to the new profile.

      Then move up to DBs. I think you might need to put all .db files in there, not just one of them (they depend on each other).

  4. Jim July 23, 2012 at 10:16 am #

    I'm deploying FF in a corporate environment. I want to have a bookmark folder and customize the button layout for our user. I have the custom localstore.rdf and bookmarks.html. Do I copy these file back into C:\Program Files\Mozilla Firefox\omni.ja or do I open up the firefox-setup.exe and replace that omni.ja. You say that firefox copies defaults/profile from the install location. I only see C:\Program Files\Mozilla Firefox\defaults\pref. On a tangent can these setting be applied if the profile is already created.

    • Mike Kaply July 24, 2012 at 11:14 am #

      You would create a new directory, defaults/profile and put the files in there.
      Don't mess with omni.ja.
      Then they will happen with new profiles.
      Modifying existing profiles is more difficult (especially localstore.rdf). You could use the CCK to modify the bookmarks.

      • Dfarha October 22, 2012 at 2:46 am #

        Hi Mike,
        i know this post from 3 months ago, but actually it does not work with me.
        i want to customize the bookmark Firefox 10, i create a new directory but No luck, any suggestion ? thank in advance.
        Regards

        • Mike Kaply April 1, 2013 at 10:01 am #

          I know this is old, but can you provide more info about the exact problem you are having?

  5. BRT July 24, 2012 at 11:12 am #

    i just want to have firefox open in a fixed location with a fixed window size every time it opens, regardless of the last window size & position when it was closed.

    looked into prefs.js in the default profile directory, was pointed to "http://www.mozilla.org/unix/customizing.html#prefs", but no luck :(

    Any ideas how this can be done?

    • Mike Kaply July 24, 2012 at 11:14 am #

      My only thought off the top of my head is to make localstore.rdf read only, then Firefox won't persist any changes...

  6. Darren Collins October 31, 2012 at 6:46 am #

    Hi Mike,

    You say:

    > Copy the files you want to modify into the directory defaults/profile underneath where the Firefox executable is located (you'll have to create this directory). When a new profile is created, these files (and any other files that are also in the directory) are copied over.

    ... which works brilliantly, but I've found that when Firefox upgrades[1] it deletes the prefs.js and localstore.rdf files it finds in the "\defaults\profile" folder.

    The prefs.js being deleted is no problem of course as the "defaultPref"s can go in the firefox.cfg (or equivalent) file. But what to do about customisations in the localstore.rdf file, if it only gets deleted when FF upgrades?

    Many thanks,
    Darren.

    [1] I've been testing with 16.0.1 upgrading to 16.0.2

    • Mike Kaply January 20, 2013 at 3:22 pm #

      This would actually be a Firefox bug.

      A Firefox upgrade should not modify files that the user has put in the directory.

      Are you on Mac or Windows.

  7. mark January 7, 2013 at 8:33 am #

    Hi
    Great Article , im currently trying to deploy firefox with some defaults pref's and now using the userChrome i can remove the home button etc.
    However is there anyway to set the default location of the default profile. for example its currently set as ~/Library/Application Support/Firefox. could i chnage this so its in ~/Library/Preferences?
    or another other location under the users profile?
    could the name be changed also?

    thanks

    • Mike Kaply January 20, 2013 at 2:59 pm #

      You can't specify the default location of all profiles, but you can specify the default location of a particular profile.

      If you start Firefox with

      -profile FULLY QUALIFIED PATH

      It will put the profile for that instance into that directory.

  8. SS May 10, 2013 at 5:46 pm #

    I have FF 17.0.5 ESR installed in a VMware View environment. I would like to know if its possible for the user profile to be created on a network share (instead of %appdata%\Mozilla). I understand how to move the profile after the fact but there must be a way to change the default location. I have reviewed this post and Google and cannot find any information on how to do this.

    thx

    • Mike Kaply May 13, 2013 at 9:02 am #

      There's no way to change the default location for all profiles, but you can start Firefox with a directory and it will put the profile into that directory. So:

      firefox -profile "Z:\foo"

      This only changes the profile for that instance of Firefox, though, so every time you start Firefox you would need to pass that path.

Leave a Reply:

Gravatar Image