Keyboardctl is a simple tool to written by the Manjaro team, that makes it possible to change both the console and X11 keyboard layout at once. The two previous config files are fused together into /etc/keyboard.conf. You can change your keyboard layout by running the command:
sudo keyboardctl -l us
In case you're using a variant of a specific keyboard layout, then you can simply add it:
sudo keyboardctl -l us colemak
The changes take effect immediately and will be saved for future sessions as well. Unfortunately, more complex situations are not possible yet. If you're looking for something more complex such as customizing a keyboard layout or switching between keyboard layouts, then you can read on for other solutions.
X11 / Xorg
Change for 1 session
It's very easy to do this, all you have to do is open a terminal and type the following:
If you use a variant of a keyboard layout, then you have to add the -variant option:
setxbmap us -variant colemak
kbctl -l be
This requires you to edit a config file. This can be found in /etc/X11/xorg.conf.d/ and is in most cases called 20-keyboard.conf or 10-evdev.conf on earlier version of Manjaro. You'll be looking for: Section "InputClass", under that section you can edit XkbLayout to your liking. For example if you want to use the Belgian keyboard layout:
Section "InputClass" Identifier "system-keyboard" MatchIsKeyboard "on" Option "XkbModel" "pc105" Option "XkbLayout" "be" Option "XkbVariant" "" EndSection
If you use a variant of a keyboard layout, then you also have to include XkbVariant:
Section "InputClass" Identifier "system-keyboard" MatchIsKeyboard "on" Option "XkbModel" "pc105" Option "XkbLayout" "us" Option "XkbVariant" "colemak" EndSection
Customize keyboard layout
You'll need 2 tools for this which are normally pre-installed: xmodmap and possibly xev. First we want to save our current keyboard layout in a config file.
xmodmap -pke > ~/.Xmodmap
Now you can open this document named .Xmodmap with your favorite text editor and change everything to your liking. When you're done, save and exit. If you're not sure what every button on your keyboard is called, then you can use xev to get all information about it. Open your terminal, type xev, then press the button of which you need more info, you'll be looking for the keycode. An example: My laptop for some reason detect my Return key as KP_Enter and that creates problems in several applications, so I replace that keycode.
keycode 36 = KP_Enter KP_Enter KP_Enter KP_Enter KP_Enter KP_Enter KP_Enter ..... This becomes the following ..... keycode 36 = Return Return Return Return Return Return Return
Now we have to apply the new keyboard layout, we do this by using the following command.
Now we have to make sure that it uses this layout every time you start X11. In order to do that you have to add the following to the autostart script of your display manager. By default Manjaro uses LXDM, so then you'll have to add this to /etc/lxdm/PostLogin. For SLiM this is .xinitrc.
if [ -f $HOME/.Xmodmap ]; then xmodmap "$HOME/.Xmodmap" fi
Switch between keyboard layouts
To switch between keyboard layouts you have to add the XkbOptions option to the InputClass section. There are 2 things you can use there: grp and grp_led. grp defines which key(s) you have to press to quickly switch between keyboard layouts. grp_led uses the LEDs on your keyboard to indicate a change, this is optional. The example below shows you how to change between the Belgian layout and the Colemak layout by pressing Alt+Shift, the Scroll Lock LED indicates the change. Note that if you for example want to use a variant in the second layout but not in the first one, you can just enter a comma to indicate that no variant is required for the first layout.
Section "InputClass" Identifier "system-keyboard" MatchIsKeyboard "on" Option "XkbModel" "pc105" Option "XkbLayout" "be,us" Option "XkbVariant" ",colemak" Option "XkbOptions" "grp:alt_shift_toggle,grp_led:scroll" EndSection
Another way to work with variants is by including them between parentheses:
Option "XkbLayout" "be,us(colemak)"
Change for 1 session
Just like with X11/Xorg this can be done with a simple command. Note that these commands are not the same as the ones we used to specify our keyboard layout in X11.
Variants have their own keymap now, there's no need for a special variant option:
All you have to do is edit this file: /etc/vconsole.conf Change the KEYMAP line to your layout. For example:
- Original forum thread: http://forum.manjaro.org/index.php?topic=1818.0