GNOME Desktop Configuration
GSettings
GNOME 3 comes with a tool called gsettings
that allows you to interact with the GConf configuration system. While there is a GUI, it can be annoying to configure a system from scratch with pointing and clicking. If you know how you like your system configured, you can automate the setup of new systems with the command-line tool. For this example, we will configure Guake.
Warning
Keep in mind that not all applications use dconf for storing their configuration. Emacs, for example, uses the ${HOME}/.emacs
file as the configuration backend.
Find the keys you want to change
For this example, we will configure Guake as follows:
- Width set to 90
- Height set to 80
- F12 configured as the hide/show key
- Alt-[ and Alt-] for switching between tabs
- Ctrl-Alt-[ and Ctrl-Alt-] for moving tabs
Method 1: grep
One way of finding the key=value pairs you want to change is by listing them all and using grep
to find the right ones. To find the Guake configuration options:
gsettings list-schemas | grep guake
You should see a list of schemas in the console:
you@local (~) ∑ gsettings list-schemas | grep guake
guake.general
guake.style.font
guake.style
guake.keybindings
guake.style.background
guake.keybindings.global
guake
guake.keybindings.local
guake.hooks
you@local (~) ∑
To list the keys in the guake.general
schema, use gsettings list-keys
(we will save a wall of text using grep):
you@local (~) ∑ gsettings list-keys guake.general | grep window
window-width
window-refocus
window-vertical-displacement
window-valignment
window-losefocus
window-halignment
set-window-title
window-tabbar
window-ontop
window-horizontal-displacement
window-height
you@local (~) ∑
To set window-height
and window-width
:
you@local (~) ∑ gsettings set guake.general window-height 80
you@local (~) ∑ gsettings set guake.general window-width 90
Validate the changes:
you@local (~) ∑ gsettings get guake.general window-height
80
you@local (~) ∑ gsettings get guake.general window-width
90
you@local (~) ∑
The full set of keys that need to be changed:
- guake.general window-width
- guake.general window-height
- guake.keybindings.global show-hide
- guake.keybindings.local next-tab
- guake.keybindings.local previous-tab
- guake.keybindings.local move-tab-right
- guake.keybindings.local move-tab-left
Method 2: dconf GUI
You can explore the dconf GUI to find the keys you would like to change, and keep track of them in the terminal using dconf watch
. To watch the entire configuration:
dconf watch /
If we navigate to Guake settings and manipulate the width, we see:
/apps/guake/general/window-width
90
Which tells us we need to modify guake.general window-width
. This process can be repeated to discover all of the keys needed.
Automation 1: Bash script
You can store the keys and values in a Bash script that can be run. An example script that accomplishes the desired configuration. An example Bash script that accomplishes this:
#!/bin/bash
declare -A settings
settings["guake.general window-width"]=90
settings["guake.general window-height"]=80
settings["guake.keybindings.global show-hide"]=F12
settings["guake.keybindings.local next-tab"]='<Alt>bracketright'
settings["guake.keybindings.local previous-tab"]='<Alt>bracketleft'
settings["guake.keybindings.local move-tab-right"]='<Primary><Alt>bracketright'
settings["guake.keybindings.local move-tab-left"]='<Primary><Alt>bracketleft'
for setting in "${!settings[@]}"
do
gsettings set ${setting} "${settings[${setting}]}"
done
You can download the script here.
Automation 2: Ansible
Ansible is a configuration automation tool developed by Red Hat. While the primary application is for managing configuration across networks, it can also be used nicely for infrequent configurations.
An example playbook.yml
that only loads variables from a file and runs gsettings
commands:
---
- hosts:
- localhost
tasks:
- name: Load OS-generic package variables
include_vars: vars/Generic.yml
- name: Configure GNOME
remote_user: "{{username}}"
shell: "gsettings set {{item.key}} '{{item.value}}'"
loop: "{{gsettings | dict2items}}"
The Generic.yml
file:
gsettings:
guake.general window-width: 90
guake.general window-height: 80
guake.keybindings.global show-hide: F12
guake.keybindings.local next-tab: '<Alt>bracketright'
guake.keybindings.local previous-tab: '<Alt>bracketleft'
guake.keybindings.local move-tab-right: '<Primary><Alt>bracketright'
guake.keybindings.local move-tab-left: '<Primary><Alt>bracketleft'
To run the playbook:
ansible-playbook playbook.yml --extra-vars username=foobar
You can download this setup here