User config directory
Chromium does use a ~/.config
directory (~/.config/chromium
- ~/.config/google-chrome
for Google Chrome), customisable using a command line flag:
~ man google-chrome | perl -00 -ne 'print if /\.config/'
--user-data-dir=DIR
Specifies the directory that user data (your "profile") is kept
in. Defaults to ~/.config/google-chrome . Separate instances
of Google Chrome must use separate user data directories;
repeated invocations of google-chrome will reuse an existing
process for a given user data directory.
So, the simplest way to create a new configuration is to run either of these with --user-dir=newconfig
, customize as needed, then copy over the newconfig
directory to /etc/skel/.config/chromium
and /etc/skel/.config/google-chrome
.
Administrative policies
The last, but perhaps the most flexible, way would be to use /etc/chromium-browser/policies
(or /etc/opt/chrome/policies
for Google Chrome). The Chromium Documentation for Administrators has pages for Windows, Mac and Linux.
Essentially, on Linux, you make use of JSON files in policies/managed
and policies/recommended
. The managed
directory is for settings that are enforced - the user can't change them.
I'll just adapt the example given for Linux:
$ cat /etc/chromium/policies/managed/test_policy.json
{
"HomepageLocation": "www.chromium.org",
"HomepageIsNewTabPage": false
}
Now, on Chromium, the homepage is locked to www.chromium.org
. Correspondingly, if the file had been in recommended
, the user can change their home page.
The current list of policies is available here. It lists policies, their descriptions and example values.
To install a theme or an extension, the ExtensionInstallForcelist
policy can be used. It can't be recommended
, only managed
:
$ cat /etc/chromium/policies/managed/test_policy.json
{
"ExtensionInstallForcelist": [
"gighmmpiobklfepjocnamgkkbiglidom;https://clients2.google.com/service/update2/crx",
"jeonacmfdmkgfmmdejlinolgjomhcbmh;https://clients2.google.com/service/update2/crx",
],
}
This will install the Adblock Extension and the GData Centers 1 Council Bluffs, Iowa theme.
/etc/chromium-browser/customizations
/etc/chromium-browser/customizations/00-example
seems to indicate it can only be used for detecting plugins and adding command line flags:
$ cat etc/chromium-browser/customizations/00-example
## Register plugins this way. The two parameters are yours to fill.
#discover_registration /path/to/plugin/plugin.info library-name
## A way to influence the running. This is read-write for you. Please
## Append only.
#CHROMIUM_FLAGS="${CHROMIUM_FLAGS} --option=value"
## Read-only variables guaranteed to be set, with example values.
#APPNAME='chromium-browser'
#BUILD_DIST='Ubuntu 14.04'
#DESKTOP_SESSION='ubuntu'
#LIBDIR='/usr/lib/chromium-browser'
#UPSTREAM_VERSION='34.0.1847.131'
(That's from 48.0.2564.116-0ubuntu0.14.04.1.1111
, by the way, despite what the UPSTREAM_VERSION
might indicate. And for some reason, only the 32-bit package on Ubuntu 14.04 has it, not the 64-bit one.)
The list of command line flags for Chromium can be found at http://peter.sh/experiments/chromium-command-line-switches/, according to
the Chromium website.
discover_registration
doesn't seem to be an executable command - it might be a shell function, but I'm inclined to suspect these files are not parsed by our normal shells. In any case, I think this method is not sufficiently versatile, and it's difficult to override if all you want is for users to start off with some settings while letting them change those later. And the flags don't seem to provide a way of installing a theme or an extension.
GSettings
A quick scan of dconf-editor
on my system indicates Google Chrome doesn't use it. Neither, apparently (thanks @Serg), does Chromium.
Conclusion
All told, either of the first two methods can be used, and Google Chrome supports whatever Chromium does, but with different paths. Where Chromium has /etc/chromium-browser
and ~/.config/chromium
, Google Chrome has /etc/opt/chrome
and ~/.config/google-chrome
, respectively. The first method is OK for one-time initialization, anything more would require the second method.
Since not all settings can be configured using policies, you might have to use both of them.
Best Answer
I wrote a small bash script that automates the excellent solution from Radu: