Elektra  0.8.26
Plugin: mozprefs

This file explains how Firefox preferences can be manipulated at run-time using Elektra’s intercept open and a custom autoconfig script.

Basics

kdb configure-firefox -s will configure everything needed to get started.

Files

1 user_pref("elektra.config.file", "/tmp/imnotreal.js");
2 user_pref("elektra.config.reload_trigger_port", 65432);

Every time the string reload is send to localhost:elektra.config.reload_trigger_port the autoconfig script will import the preferences from elektra.config.file
elektry.config.file contains the name of the dummy file for intercept open. open calls to this file will be intercepted and the content generated by intercept open

Setting preferences

Guided setup

Running kdb configure-firefox -a provides a guided setup for adding http_proxy and homepage preferences.

1 % kdb configure-firefox -a
2 Add new preferences
3 Config Setup:
4 
5 1) Proxy
6 2) Homepage
7 0) Exit
8 1
9 
10 Setting up HTTP Proxy
11 1) lock
12 2) default
13 3) user
14 0) Exit
15 1
16 
17 Proxy Type
18 0) No Proxy
19 1) Manual Setup
20 2) PAC
21 4) Auto-detect
22 5) System Settings
23 1
24 
25 Set string to 1
26 Host/IP: 127.0.0.1
27 Port: 8080
28 Setting lockPref HTTP Proxy to 127.0.0.1:8080

Manual setup

This example shows how to manually setup a preferences. It's equivalent to the example shown above in the Guided setup

1 kdb setmeta user/prefs/lock/network/proxy/type type integer
2 kdb set user/prefs/lock/network/proxy/type 1
3 kdb setmeta user/prefs/lock/network/proxy/http type string
4 kdb set user/prefs/lock/network/proxy/http 127.0.0.1
5 kdb setmeta user/prefs/lock/network/proxy/http_port type integer
6 kdb set user/prefs/lock/network/proxy/http_port 8080

Test Setup

Running kdb configure-firefox -t will set up some test values.

1 % kdb export /preload
2 
3 [open]
4 \/tmp\/imnotreal.js =
5 \/tmp\/imnotreal.js/generate = user/prefs
6 \/tmp\/imnotreal.js/generate/plugin = mozprefs
7 
8 
9 % kdb export user/prefs
10 
11 [lock/a/lock]
12 1 = lock1
13 2 = lock2
14 [pref/a/default]
15 1 = 1
16 2 = 2
17 [user/a/user]
18 f = false
19 t = true
20 
21 % kdb export user/prefs mozprefs
22 
23 lockPref("a.lock.1", "lock1");
24 lockPref("a.lock.2", "lock2");
25 pref("a.default.1", 1);
26 pref("a.default.2", 2);
27 user_pref("a.user.f", false);
28 user_pref("a.user.t", true);
1 % kdb elektrify-open firefox-esr "about:config"
about:config before
1 % kdb setmeta user/prefs/lock/a/lock/3 type boolean
2 % kdb set user/prefs/lock/a/lock/3 true
3 % kdb export user/prefs
4 
5 [lock/a/lock]
6 1 = lock1
7 2 = lock2
8 3 = true
9 [pref/a/default]
10 1 = 1
11 2 = 2
12 [user/a/user]
13 f = false
14 t = true
about:config after

Limitations

Changing locked values doesn't work without restarting.