Declarative configuration management for Zen Browser. Define your complete browser setup—extensions, preferences, containers, and workspaces—in a single YAML file.
This tool is built specifically for Zen Browser, but the underlying approach works with any Firefox-based browser. The core mechanisms—user.js for preferences and policies.json for extensions/certificates—are standard Firefox features.
Adapting for other Firefox forks (LibreWolf, Waterfox, Floorp, etc.):
- Update the installation path in
profile.zen_path(e.g.,/usr/lib/librewolfinstead of/usr/lib/zen-browser) - Update the profile directory (e.g.,
~/.librewolfinstead of~/.zen) - Remove or adapt Zen-specific features (
zen_mods,zen.*preferences) - Probably something else I haven't thought about yet
The extension management, container setup, toolbar customization, and certificate import will (hopefully) work unchanged.
- Declarative Configuration: Define everything in
config.yaml - Extension Management: Automatically install extensions via Firefox policies
- Toolbar Customization: Declaratively configure toolbar layout and button positions
- Semi-Automated Mods: Script opens mod installation pages - you just click "Install"
- Certificate Import: Automatically import CA certificates for corporate networks
- Container Configuration: Set up Multi-Account Containers with domain assignments
- Custom Search Engines: Set your default search engine
- Interactive Setup Guide: HTML checklist for manual configuration steps
- Reproducible: Go from empty
.zenfolder to fully configured browser - Version Control Friendly: Track your browser configuration in git
- Clone this repository:
git clone <repo-url>
cd browser-conf- Install dependencies with uv:
uv sync- Copy the example configuration:
cp examples/config.yaml config.yaml- Edit
config.yamlto your preferences:
$EDITOR config.yaml- Apply the configuration:
uv run zen-apply config.yamlThe script will:
- Detect your Zen Browser installation and profile
- Generate
user.jswith your preferences - Install
policies.jsonfor extensions and default search engine (requires sudo) - Import CA certificates from
./certificatesdirectory (if present) - Open Zen mod pages in your browser for easy installation
- Generate a setup guide (
~/.zen/setup-guide.html) for manual steps - Set up containers
- Complete the manual steps in the setup guide that opens in your browser:
- Click "Install" on each Zen mod page
- Set up workspaces (optional)
- Pin essential tabs (optional)
See examples/config.yaml for a fully documented configuration example.
- profile: Profile name and Zen installation path
- extensions: Extensions to auto-install via Firefox policies
- config: Unified browser configuration using nested YAML (Firefox and Zen preferences)
- toolbar: Declarative toolbar layout and button positions
- zen_mods: CSS-based themes/customizations from the Zen theme store
- certificates_dir: Directory containing CA certificates to import (.crt or .pem files)
- default_search_engine: Set your default search engine
- containers: Container definitions (name, color, icon)
- extension_settings: Configure extension settings (e.g., Bitwarden server URL)
The config section uses nested YAML for all browser preferences (both Firefox and Zen). The nesting is automatically flattened to dot-notation when generating user.js:
config:
# Firefox preferences
privacy:
trackingprotection:
enabled: true
browser:
startup:
homepage: "about:blank"
# Zen preferences (use zen.* prefix)
zen:
view:
compact: true
tabs:
vertical: trueThis generates:
user_pref("privacy.trackingprotection.enabled", true);
user_pref("browser.startup.homepage", "about:blank");
user_pref("zen.view.compact", true);
user_pref("zen.tabs.vertical", true);Note: For backward compatibility, the old format (preferences and zen as separate sections) is still supported.
- Zen Browser (native installation)
- Python 3.11+
- uv (Python package manager)
- sudo access (for installing policies.json)
User preferences are written to ~/.zen/<profile>/user.js. This file is automatically loaded by Firefox/Zen on startup and overrides default preferences.
Extensions are installed via policies.json placed in the Zen installation directory (/usr/lib/zen-browser/distribution/policies.json). This requires elevated permissions.
Containers are configured via Firefox policies. They are created automatically by Firefox/Zen when the browser starts.
Zen mods are CSS-based themes and customizations from the Zen theme store. The script provides semi-automated installation:
- Fetches the theme store catalog from GitHub
- Finds your configured mods by UUID or name
- Opens each mod's installation page directly in Zen Browser (
zen-browser <url>) - You simply click "Install" on each page
This approach works around Zen Browser's limitation that mods must be installed through the UI - the script does all the work of finding the right pages and opening them for you.
You can specify mods by their UUID or name. Browse available mods at zen-browser.app/mods.
Declaratively configure your toolbar layout, button positions, and widget placements:
How to set up:
Option 1: Using the helper script (easiest)
- Customize your toolbar manually in Zen Browser (right-click toolbar → "Customize Toolbar...")
- Go to
about:config - Search for
browser.uiCustomization.state - Copy the JSON value
- Run the helper script:
uv run json-to-yaml
- Paste the JSON and press Ctrl+D
- Copy the YAML output into your config.yaml
Option 2: Manual conversion
- Customize your toolbar in Zen Browser
- Go to
about:configand copybrowser.uiCustomization.state - Convert the JSON to YAML format manually
- Paste it into your config under the
toolbarsection
Example:
toolbar:
placements:
widget-overflow-fixed-list: []
unified-extensions-area:
- ublock0_raymondhill_net-browser-action
nav-bar:
- back-button
- forward-button
- stop-reload-button
- urlbar-container
- downloads-button
TabsToolbar:
- tabbrowser-tabs
seen:
- developer-button
- ublock0_raymondhill_net-browser-action
currentVersion: 20The toolbar state is written to user.js as browser.uiCustomization.state and applied on browser startup.
For configuration that cannot be automated (workspaces, essential tabs), the script generates an HTML setup guide at ~/.zen/setup-guide.html. This guide:
- Lists all manual configuration steps with clear instructions
- Includes checkboxes to track your progress
- Links directly to all mod installation pages
- Opens automatically in your browser when the script completes
Import custom CA certificates (e.g., for corporate networks, self-signed certificates) using the certificates_dir option:
- Place your certificate files (
.crtor.pem) in the configured directory (default:./certificates) - The script includes them in
policies.jsonusing Firefox'sCertificates.Installpolicy - Firefox/Zen automatically imports them on startup - no external tools needed!
Example:
certificates_dir: certificates # Relative to config fileThen add your certificates:
certificates/
├── company-root-ca.crt
└── internal-ca.pem
The generated policies.json will include:
"Certificates": {
"Install": [
"/absolute/path/to/certificates/company-root-ca.crt",
"/absolute/path/to/certificates/internal-ca.pem"
]
}Make sure policies.json is installed correctly:
cat /usr/lib/zen-browser/distribution/policies.jsonIf the file doesn't exist, the script may not have had sufficient permissions.
Check that user.js was created:
cat ~/.zen/<profile-name>.default/user.jsRestart Zen Browser after applying configuration.