Ubuntu – Where are the Keyboard Settings Stored in MATE DE

16.0418.0418.10keyboard-layoutmate

I'm currently setting up a couple of computers with Ubuntu MATE 16.04. The default installation sets the Keyboard Layout to 'English', however, I need a 'German' keyboard layout. I figured out how to remove all Layouts and add 'German' as default keyboard layout in the GUI.

System -> Preferences -> Hardware -> Keyboard -> Layouts

However, I have to setup around 20 computers and it would be neat if I could script those settings. So my questions is where are the keyboard settings stored such that I could copy it from one computer to all the others.

Best Answer

1. MATE Desktop Environment session

1.1. Using gsettings

You need the following GSettings keys. Below is my example with two layouts (us and ru) using Ctrl+Shift as layout switcher and ScrollLock LED as indicator of the second layout:

gsettings set org.mate.peripherals-keyboard-xkb.kbd layouts "['us', 'ru']"
gsettings set org.mate.peripherals-keyboard-xkb.kbd model "''"
gsettings set org.mate.peripherals-keyboard-xkb.kbd options \
"['grp_led\tgrp_led:scroll', 'grp\tgrp:ctrl_shift_toggle']"

Edit it for your case.

1.2. Using dconf

Alternative method is to use dconf command:

cat <<EOF | dconf load /org/mate/desktop/peripherals/keyboard/
[kbd]
layouts=['us', 'ru']
model=''
options=['grp_led\tgrp_led:scroll', 'grp\tgrp:ctrl_shift_toggle']
EOF

Edit it for your case.

2. Terminal session and some GUI cases

Do not forget to run sudo dpkg-reconfigure keyboard-configuration to reconfigure keyboard layouts for terminal and some GUI sessions.
It will save its settings in /etc/default/keyboard.
You can configure it once, then copy this file to other machines. After changing this file you should update initramfs images with sudo update-initramfs -k all -u.


Also note, that MATE Keyboard Preferences may be opened with mate-keyboard-properties.