Hi,
I once wrote an article for Ubuntuusers.de that deals with localectl and allows switching the keyboard layout. Maybe this article will help you. I just copied it out and translated it. There are still commands with apt-get available, which of course you would have to adjust but otherwise everything complies with the specifications. With that you could switch your layout with HotKeys. Please read and understand first before changing anything.
I hope it helps you.
`With localectl all necessary information can be queried and settings can be made to set the system locale and the corresponding keyboard layout. This is sometimes necessary because incorrect settings have been made during the installation and / or updates or software installations have lost the default settings. localectl is preinstalled on every Ubuntu system and is operated exclusively via the terminal.
The system locale controls the language settings of the system services and the user interface before the user logs on, e.g. the display manager, as well as the standard for users after logging in. The keyboard settings control the graphical user interface keyboard layout used on the text console and keyboard before the user logs on, e.g. the display manager, as well as the default value for users after login.
installation
localectl is part of systemd. Since systemd since Ubuntu 15.04 is an integral part of the system (and since this is not executable without systemd), all required components are already installed.
use
Determine data
With
localect status
determine the current settings. The output should look something like this:
System Locale: LANG = en_DE.UTF-8
LANGUAGE = en: de_CH: en_GB: en
VC Keymap: de
X11 layout: de
X11 Model: pc105
This output is only an example and does not reflect the actual output, which varies from PC to PC.
Determine parameters
Change locale
Prerequisite is an installed German language pack. That can be made up:
language-pack-de
Wiki / Templates / Installbutton / button.png with apturl
Package list for copying: apt-get aptitude
sudo apt-get install language-pack-DE
If the desktop is in English, you can change that very quickly with:
sudo localectl set-locale LC_MESSAGES = en_GB.utf8 LANG = en_DE.UTF-8
After reading the locale files again
sudo update-locale
all settings should have been adopted throughout the system.
Change keyboard layout
In some cases it is necessary to change the keyboard layout, because during installation qwerty was set instead of qwertz for the German language area.
Attention!
Wrong settings can lead to an almost unusable keyboard!
Again, you should determine how many keys are available. The manual or a web search for the existing model should provide information. In some cases, it also helps to query USB-attached keyboards. With
lsusb
determine the necessary data such as manufacturer and product ID and enter them in this example.
lsusb -vd MANUFACTURER ID: PRODUCT ID
To set all settings in a command line, this command is provided.
localectl set-x11-keymap LAYOUT MODEL VARIANT OPTION
If you are sure which model is available, the necessary settings can be made.
An example of a German keyboard with 105 keys, without dead keys and the Compose key on the right Windows key:
sudo localectl set-x11-keymap pc105 nodeadkeys compose: rwin
The issue of
localect status
shows the result:
System Locale: LANG = en_DE.UTF-8
VC Keymap: de-latin1-nodeadkeys
X11 layout: de
X11 Model: pc105
X11 Variant: nodeadkeys
X11 Options: compose: rwin
As you can see on the output, all settings have been done with a command line.
The command
sudo update-locale
should also take over the settings system-wide.
They are e.g. more keyboard layouts possible, which can be easily switched by keyboard shortcut. This is what the command is for
set-keymap MAP [TOGGLEMAP]
With
localectl list-x11-keymap-options
Toggle presets can be selected. After presenting the example above, you could also in addition
grp: rctrl_rshift_toggle
enter as a toggle keyboard combination.
Example:
sudo localectl set-x11-keymap, us pc105 nodeadkeys grp: rctrl_rshift_toggle, compose: rwin
Now you can switch between qwertz (de) and qwerty (us) with the keyboard combination Ctrl + ⇧ on the right side.
options
Description of options
setting Description
-h Show the help
--no-convert Prevents set-keymap from also changing the xorg layout or set-x11-keymap changing the layout for the console.
status Shows the current settings.
set-locale Sets the system locale, one or more mappings, such as LANG = de_DE.utf8 and / or LC_MESSAGES = en_US.utf8.
list-locales List of available system locales available for configuration with set-locale.
set-keymap Sets the mapping for the console and X11. This will require an assignment name (such as de or us) and possibly a second one to define a toggle keyboard mapping, unless --no-convert is passed.
list-keymaps List of available keyboard mappings for the console.
set-x11-keymap Sets the default keyboard mapping for X11 and the virtual console. Keyboard mapping name like de or us and maybe a model.
list-x11-keymap-models List of keyboard models.
list-x11-keymap-layouts List of all keyboard layouts.
list-x11-keymap-variants Shows different variants.
list-x11-keymap-options More options, such as: the setting of the Compose button.
To make working at the terminal easier, lists can also be passed to less. The display can then be easily ended with the Q key.
Example:
localectl list-x11-keymap-models | less
Note:
When setting settings via localectl, the files /etc/vconsole.conf, / etc / default / keyboard and /etc/locale.conf - if the file exists - or / etc / default / locale can be overwritten.
Since localed was patched for Ubuntu, no /etc/X11/xorg.conf.d/00-keyboard.conf is generated, unlike the upstream behavior. If the X server is started without utilities that honor the / etc / default / keyboard, this file must be created manually if necessary (the syntax is outlined in Language Settings ("Command Line" section)) to change the keyboard layout of the X- Set the server.
Further information can be found in the man page.`