This file explains how Firefox preferences can be manipulated at runtime using Elektras intercept open and a custom autoconfig script.

\subsection*{Basics}

{\ttfamily kdb configure-\/firefox -\/s} will configure everything needed to get started.

\subsubsection*{Files}


\begin{DoxyItemize}
\item {\ttfamily /usr/lib/firefox} / {\ttfamily /usr/lib/firefox-\/esr}
\begin{DoxyItemize}
\item {\ttfamily defaults/pref/autoconfig.\+js} Loads {\ttfamily elektra.\+cfg}
\end{DoxyItemize}
\end{DoxyItemize}

\begin{DoxyVerb} ```
 pref("general.config.filename", "elektra.cfg");
 pref("general.config.obscure_value", 0);
```
\end{DoxyVerb}

\begin{DoxyItemize}
\item {\ttfamily elektra.\+cfg} Contains the autoconfig code
\end{DoxyItemize}

{\ttfamily $\sim$/.mozilla/firefox/$<$profile$>$/prefs.js} Contains the user preferences. The configure-\/firefox script will append the config for our autoconfig script\+:

``` user\+\_\+pref(\char`\"{}elektra.\+config.\+file\char`\"{}, \char`\"{}/tmp/imnotreal.\+js\char`\"{}); user\+\_\+pref(\char`\"{}elektra.\+config.\+reload\+\_\+trigger\+\_\+port\char`\"{}, 65432); ```

Every time the string {\ttfamily reload} is send to localhost\+:{\ttfamily elektra.\+config.\+reload\+\_\+trigger\+\_\+port} the autoconfig script will import the preferences from {\ttfamily elektra.\+config.\+file}

{\ttfamily elektry.\+config.\+file} contains the name of the dummy file for {\ttfamily intercept open}. {\ttfamily open} calls to this file will be intercepted and the content generated by {\ttfamily intercept open}

\subsubsection*{Setting preferences}

\paragraph*{Guided setup}

Running {\ttfamily kdb configure-\/firefox -\/a} provides a guided setup for adding http\+\_\+proxy and homepage preferences.

``` \% kdb configure-\/firefox -\/a Add new preferences Config Setup\+:

1) Proxy 2) Homepage 0) Exit 1

Setting up H\+T\+T\+P Proxy 1) lock 2) default 3) user 0) Exit 1

Proxy Type 0) No Proxy 1) Manual Setup 2) P\+A\+C 4) Auto-\/detect 5) System Settings 1

Set string to 1 Host/\+I\+P\+: 127.\+0.\+0.\+1 Port\+: 8080 Setting lock\+Pref H\+T\+T\+P Proxy to 127.\+0.\+0.\+1\+:8080 ```

\paragraph*{Manual setup}

This example shows how to manually setup a preferences. It's equivalent to the example shown above in the {\ttfamily Guided setup} ``` kdb setmeta user/prefs/lock/network/proxy/type type integer kdb set user/prefs/lock/network/proxy/type 1 kdb setmeta user/prefs/lock/network/proxy/http type string kdb set user/prefs/lock/network/proxy/http 127.\+0.\+0.\+1 kdb setmeta user/prefs/lock/network/proxy/http\+\_\+port type integer kdb set user/prefs/lock/network/proxy/http\+\_\+port 8080 ```

\subsubsection*{Test Setup}

Running {\ttfamily kdb configure-\/firefox -\/t} will set up some test values.

``` \% kdb export /preload

\mbox{[}open\mbox{]} \textbackslash{}/tmp\textbackslash{}/imnotreal.js = \textbackslash{}/tmp\textbackslash{}/imnotreal.js/generate = user/prefs \textbackslash{}/tmp\textbackslash{}/imnotreal.js/generate/plugin = mozprefs

\% kdb export user/prefs

\mbox{[}lock/a/lock\mbox{]} 1 = lock1 2 = lock2 \mbox{[}pref/a/default\mbox{]} 1 = 1 2 = 2 \mbox{[}user/a/user\mbox{]} f = false t = true

\% kdb export user/prefs mozprefs

lock\+Pref(\char`\"{}a.\+lock.\+1\char`\"{}, \char`\"{}lock1\char`\"{}); lock\+Pref(\char`\"{}a.\+lock.\+2\char`\"{}, \char`\"{}lock2\char`\"{}); pref(\char`\"{}a.\+default.\+1\char`\"{}, 1); pref(\char`\"{}a.\+default.\+2\char`\"{}, 2); user\+\_\+pref(\char`\"{}a.\+user.\+f\char`\"{}, false); user\+\_\+pref(\char`\"{}a.\+user.\+t\char`\"{}, true); ```

``` \% kdb elektrify-\/open firefox-\/esr \char`\"{}about\+:config\char`\"{} ```

 ``` \% kdb setmeta user/prefs/lock/a/lock/3 type boolean \% kdb set user/prefs/lock/a/lock/3 true \% kdb export user/prefs

\mbox{[}lock/a/lock\mbox{]} 1 = lock1 2 = lock2 3 = true \mbox{[}pref/a/default\mbox{]} 1 = 1 2 = 2 \mbox{[}user/a/user\mbox{]} f = false t = true ``` 

\subsection*{Limitations}

Changing locked values doesn't work without restarting. 