How to set cinnamon preferences in command line?

I am using LinuxMint 17 (Qiana) with Cinnamon, and I am creating a script to re-create my system in case my computer dies or I need to migrate computers.

Its easy to make a script to install/remove packages that I want/dislike and transfer my files, but I cannot seem to find a way to change system preferences via command line.

Ideally, I would like options that can sets things like panel location, panel height, panel background, applets in the panel, default system fonts, and possibly even desktop background. Currently, the best idea/suggestion I have is to copy the hidden folders in my $HOME directory, which contain some of the settings.

Any suggestions to do this programmatically, without having to copy files?


Solution 1:

I have since a couple of years ago, also kept a script to maintain the config for my environment(s) in one script file.

There are three types of settings in Cinnamon:

  1. DConf settings for most Cinnamon specifics.
  2. .cinnamon configs for some Cinnamon components.
  3. Random config files, each being application specific (such as browsers, terminals, etc.).

And there are many settings that are either not easy to configure or just not available to configure.

So, depends on what you need?

Here are examples of some of the settings I use...

For the Cinnamon configurations, a lot can be done with simple commands, such as, for the Nemo File Manager:

dconf write /org/nemo/preferences/show-hidden-files true
dconf write /org/nemo/preferences/show-image-thumbnails "'never'"
dconf write /org/nemo/preferences/show-full-path-titles true
dconf write /org/nemo/preferences/quick-renames-with-pause-in-between true
dconf write /org/nemo/preferences/show-advanced-permissions true
dconf write /org/nemo/preferences/show-home-icon-toolbar true
dconf write /org/nemo/preferences/show-new-folder-icon-toolbar true
dconf write /org/nemo/preferences/show-compact-view-icon-toolbar false
dconf write /org/nemo/preferences/show-icon-view-icon-toolbar false
dconf write /org/nemo/preferences/show-list-view-icon-toolbar false
dconf write /org/nemo/preferences/show-open-in-terminal-toolbar true
dconf write /org/nemo/list-view/default-visible-columns "['name', 'size', 'type', 'date_modified', 'owner', 'permissions']"

Or, for general Cinnamon desktop:

##### Desktop settings.
dconf write /org/cinnamon/desktop/wm/preferences/num-workspaces 2

dconf write /org/cinnamon/desktop/background/picture-uri "'file:///usr/share/backgrounds/linuxmint-qiana/j_baer_5976503592.jpg'"
dconf write /org/cinnamon/desktop/background/color-shading-type "'solid'"
dconf write /org/cinnamon/desktop/background/picture-options "'zoom'"

dconf write /org/cinnamon/desktop/background/slideshow/image-source "'xml:///usr/share/cinnamon-background-properties/linuxmint-qiana.xml'"

dconf write /org/cinnamon/startup-animation false
dconf write /org/cinnamon/desktop-effects false

dconf write /org/cinnamon/desklet-decorations 0
dconf write /org/cinnamon/enabled-desklets "['[email protected]:0:150:0']"

dconf write /org/cinnamon/panels-resizable "['1:true']" # This must be true for the following height to take effect.
dconf write /org/cinnamon/panels-height "['1:33']"

dconf write /org/cinnamon/desktop/interface/clock-show-date true

##### Sound settings.
dconf write /org/cinnamon/sounds/login-enabled false
dconf write /org/cinnamon/sounds/logout-enabled false
dconf write /org/cinnamon/sounds/unplug-enabled false
dconf write /org/cinnamon/sounds/tile-enabled false
dconf write /org/cinnamon/sounds/plug-enabled false
dconf write /org/cinnamon/sounds/switch-enabled false

##### Touchpad/mouse settings.
dconf write /org/cinnamon/settings-daemon/peripherals/touchpad/natural-scroll false
dconf write /org/cinnamon/settings-daemon/peripherals/touchpad/scroll-method "'two-finger-scrolling'"
dconf write /org/cinnamon/settings-daemon/peripherals/touchpad/motion-acceleration 5.4820717131474108 # A fraction is needed.
dconf write /org/cinnamon/settings-daemon/peripherals/touchpad/horiz-scroll-enabled false
dconf write /org/cinnamon/settings-daemon/peripherals/touchpad/two-finger-click 3
dconf write /org/cinnamon/settings-daemon/peripherals/touchpad/disable-while-typing true
dconf write /org/cinnamon/settings-daemon/peripherals/touchpad/three-finger-click 2
dconf write /org/cinnamon/settings-daemon/peripherals/touchpad/motion-threshold 2

##### Power settings.
dconf write /org/cinnamon/settings-daemon/plugins/power/button-power "'interactive'"
dconf write /org/cinnamon/settings-daemon/plugins/power/sleep-inactive-ac-timeout 0
dconf write /org/cinnamon/settings-daemon/plugins/power/critical-battery-action "'hibernate'"
dconf write /org/cinnamon/settings-daemon/plugins/power/idle-dim-time 90
dconf write /org/cinnamon/settings-daemon/plugins/power/sleep-inactive-battery-timeout 0
dconf write /org/cinnamon/settings-daemon/plugins/power/lid-close-ac-action "'nothing'"
dconf write /org/cinnamon/settings-daemon/plugins/power/lid-close-battery-action "'nothing'"
dconf write /org/cinnamon/settings-daemon/plugins/power/idle-brightness 30
dconf write /org/cinnamon/settings-daemon/plugins/power/sleep-display-ac 600
dconf write /org/cinnamon/settings-daemon/plugins/power/sleep-display-battery 600

##### Default terminal
dconf write /org/cinnamon/desktop/applications/terminal/exec "'/usr/bin/terminator'"

These are all written to "~/.config/dconf/user". To read them back (and indeed to call the above commands), install "dconf-cli", and run command:

dconf dump /

And for the various Cinnamon components that use JSON settings, look here:

~/.cinnamon/configs/

Is there something more specific, or application specific you need?

Solution 2:

For LinuxMint 19 (possibly other versions as well), these settings can be adjusted from the command line using gsettings.

For example, if I want to turn off specific cinnamon sounds (e.g. the startup sound), I might first find where sound settings are kept, by searching the list of setting schemas for relevant keywords (e.g. sound):

gsettings list-schemas | grep sound

This will print a list of schemas to stdout. You can explore all setting key-value pairs contained by a given schema by passing the schema names to list-recursively:

gsettings list-recursively org.cinnamon.sounds

Once you have identified the setting you want to change (e.g. org.cinnamon.sounds login-enabled), you can change that setting in your script quite easily. For example:

gsettings set org.cinnamon.sounds login-enabled false

As is common with command-line utilities, gsettings [commnd] -h will give you the helptext.

Thanks to MrEen at the LinuxMint forums for help putting this all together.