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.


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/
layouts=['us', 'ru']
options=['grp_led\tgrp_led:scroll', 'grp\tgrp:ctrl_shift_toggle']

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.