How can one change a Firefox config setting from the CLI

Solution 1:

I can't find any way to reload the prefs.js file (that's where firefox stores its settings) after changing it from the command line. That's a shame 'cause that would have been the simplest way of doing it.

However, for the specific setting you want to change, you could simply set up a proxy.pac file which checks if your IP is in a particular subnet and only sets up a proxy if it is:

if (isInNet(myIpAddress(), "192.168.1.0", "255.252.0.0")) { 
     proxy = "PROXY 123.456.789.100:12345";
}
else{
     proxy = "DIRECT";
}
return proxy;

Obviously, you should use your actual proxy's URL and port. You'll also need to modify it so it runs the correct tests (IP range etc) for your setup.

Now, open the proxy setting tab, select the "Automatic proxy configuration URL" and point it to: file:////path/to/proxy.pac. Restart firefox and you should now have your proxy set automatically depending on your IP address.

See here for more details.