Firefox AutoConfig

Posted on Dec 9, 2023

I’ve always found managing bookmarks in Firefox a bit annoying, specifically around how it always defaults to adding a new bookmark in the last used bookmark folder. There are extensions out there, however if the developers no longer update them, that can potentially disrupt my workflow in the future – so I opted to keeping it as reproducable as possible.

Wanting to finally investigate setting some standard settings without having to manually do anything each time I set Firefox up, I looked into AutoConfig.

The documentation isn’t necessarily super clear over where you should set parameters exactly, especially so when using a Unix-like OS, in my case Debian. The two files I needed to create were /usr/lib/firefox/defaults/pref/autoconfig.js and /usr/lib/firefox/firefox.cfg with the former only containing the following lines:

pref("general.config.filename", "firefox.cfg");
pref("general.config.obscure_value", 0);****

The first line specifies the name of the config file in /usr/lib/firefox/ that will contain our parameters. The name can differ, however the root directory in where it lives cannot.

Note that in the case of both files, they should start with a comment line.

The latter file is where we place our custom parameters. In my case, it only contains the setting for the default bookmark folder:

lockPref("browser.bookmarks.defaultLocation", "Ni5bPmZXb1vf");

The above is the unique ID (UID) of the bookmark folder (Other Bookmarks/Unfiled in my case), and took a little bit of figuring out.

Firefox has three default bookmark folders where bookmarks and other folders can exist, however the user-friendly names that we see aren’t like-for-like with their actual values when configuring:

User-friendly name ID
Bookmarks Toolbar toolbar
Bookmarks Menu menu
Other Bookmarks unfiled

I found it funny that the name I wanted to go with is the ID of the Other Bookmarks folder where my Unfiled folder lives in. If I set browser.bookmarks.defaultLocation to unfiled, it would indeed permanently set this to Other Bookmarks by default and switching back to this after I had set a different location – good! This isn’t where I wanted the bookmarks to be directed to however.

Setting the value to unfiled/Unfiled didn’t work at all, which was half not surprising and half disappointing. You have to set the UID of the folder instead. The “easiest” way I found to get this value is to:

  1. Ensure the browser.bookmarks.defaultLocation line is commented out in firefox.cfg
  2. Restart Firefox if you did have to comment it out for changes to apply
  3. Relaunch Firefox and bookmark any random page, saving it to the folder you wish to be the default
  4. Head to about:config from the address bar and search for browser.bookmarks.defaultLocation, which will be set to the folder you last saved to

In my case, I saw the below, providing me with the UID of the folder.

That’s it! After setting that as the value in firefox.cfg (ensuring that the line isn’t commented out anymore), and restarting Firefox, the default bookmarks folder was set for me.

There are some things to be aware of here that I haven’t accounted for yet…

  • I haven’t tested this on another system, so the UID may very well be unique to my current profile (I should test this)
  • I use Firefox browser Sync to keep bookmarks synced up across different machines, which may result in the structure of the UID being different (I should also test this on a different profile while signed out)