An overview of Mozilla preference files

Sep 15, '03 09:09:00AM

Contributed by: jtoher

You can pre-configure Mozilla so that all users get the same preferences when they create a new profile. For example, you might want to define a preference for /tmp, or /Users/Shared as the cache directory, so that users with network home directories will use the local drive for cache.  These prefs are stored in a javascript file called user.js which needs to be saved to /Applications -> Mozilla.app (control-click and select "Show Package Contents") -> Contents -> MacOS -> defaults -> profile -> US -> user.js. In your user.js file, lines which begin // are comments, so you could enter, for example:

//
// user.js: Personal prefs which mozilla shouldn't overwrite.
//
user_pref("browser.startup.homepage", "http://www.my.server.edu/");
user_pref("intl.accept_languages", "en-au, en, en-us, zh, zh-cn, zh-hk, zh-sg, zh-tw, fr, de, de-de, de-at, it, ja, pl, ru, es, sv, fi, sr, hr, da, nl, fr-ca, fr-fr, id, in");
user_pref("intl.charset.default", "UTF-7");

Note that user.js has unix line endings, so use a command line text editor, like vi or pico for editing ... or use BBEdit with the appropriate setting.

For the sake of completeness, I've got the same file at /Applications -> Mozilla.app -> Contents -> MacOS -> defaults -> profile -> user.js, which is where it should be, except that the version I downloaded from mozilla.org turned out to be a US build.

Whenever a new profile is created, a copy of user.js is automatically written to ~/Library -> Mozilla -> Profiles -> profile_name -> randomString.slt -> user.js. When Mozilla runs, it reads its preferences first from that profile, and lastly from the application directory:

  1. ~/Library -> Mozilla -> Profiles -> profile_Name -> randomString.slt -> prefs.js -- stored from last session
  2. ~/Library -> Mozilla -> Profiles -> profile_Name -> randomString.slt -> user.js -- persistent prefs
  3. /Applications -> Mozilla.app -> Contents -> MacOS -> defaults -> pref -> all.js -- persistent admin prefs
prefs.js is re-created by the application every time it runs. user.js is persistent and overwrites prefs.js at launch time. A savvy user could edit user.js or delete it altogether. Then all.js is the last to load and overwrites all the others. You can hack all.js to force preferences on everyone (including existing profiles), or reduce Mozilla to jelly if you are not careful.

I set up Mozilla so the preferences were as I wanted, then quit. Next I copied the lines I wanted from prefs.js to my own user.js file. Then I saved user.js to /Applications -> Mozilla.app -> Contents -> MacOS -> defaults -> profile -> US -> user.js, so that everyone would get these prefs whenever they created a new profile.

You can read more documentation in mozilla.org's A Brief Guide to Mozilla+Netscape Preferences.

Comments (2)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20030909025258993