Jun Aruga's Blog

Output, activities, memo and etc.

i3: Set up Czech input environment 2

I wrote the article to set up Czech keyboard input environment.


This time I would share what I improved for the topic, as I heard the info from my colleagues. Thanks!

The key command is setxkbmap (= Set X keyboard map).

See manual page

$ man setxkbmap
SETXKBMAP(1)                           General Commands Manual                           SETXKBMAP(1)

       setxkbmap - set the keyboard using the X Keyboard Extension

       setxkbmap [ args ] [ layout [ variant [ option ...  ] ] ]

       The  setxkbmap command maps the keyboard to use the layout determined by the options specified
       on the command line.

       An XKB keymap is constructed from a number of components which are compiled  only  as  needed.
       The source for all of the components can be found in /usr/share/X11/xkb.

For the option's value with the key, see the man xkeyboard-config - OPTIONS - Switching to another layout.

Show the current config.

$ setxkbmap -query

$ setxkbmap -print -verbose 10

Reset the config.

When we want to reset the config by setxkbmap, run the following command. Because as a behavior of setxkbmap, the config is just only added.

$ setxkbmap -layout us -option

Set up the improved Czech keyboard input environment.

There are 2 useful options so far.

Standard Czech keyboard

This command is to use the standard Czech keyboard map by toggling with windows key + space key. The motion is same with Mac's one (apple key + space key) to change the key board. So, it looks good.

$ setxkbmap -layout us -option

$ setxkbmap -layout us,cz -option grp:win_space_toggle

$ setxkbmap -query
rules:      evdev
model:      pc105
layout:     us,cz
options:    grp:win_space_toggle

Here is the layout. The red color bottoms are a function key to use Czech extra characters. The function key + a key is to input the extra characters.



There is stickers to memorize the keys.


UCW Czech keyboard

$ setxkbmap -layout us -option

$ setxkbmap -layout us,cz -variant ,ucw -option grp:caps_switch

$ setxkbmap -query
rules:      evdev
model:      pc105
layout:     us,cz
variant:    ,ucw
options:    grp:caps_switch


For example,

  • "ů" = capslock + u
  • "ú" = capslock + h

If I remember the key positions, it is the best to input Czech effectively.

Compose key

There is a compose key feature. But it looks intuitive.

In the following case, I am using CapsLock key as compose key.

$ setxkbmap -layout us -option

$ setxkbmap -option compose:caps

$ setxkbmap -query
rules:      evdev
model:      pc105
layout:     us
options:    compose:caps

For example the extra Czech characters,

  • "ů" = compose key + o + u
  • "á" = compose key + ' (single quote) + a
  • "ě" = compose key + c + e


Linux keyboard text symbols: Compose key shortcuts

i3 config

So, I am using the following updated setting.

$ vi .config/i3/config
exec --no-startup-id "setxkbmap -layout us,cz -option grp:win_space_toggle"
# exec --no-startup-id "setxkbmap -layout us,cz -variant ,ucw -option grp:caps_switch"
# exec --no-startup-id "setxkbmap -option compose:caps"
$ vi ~/.bashrc
# Keyboard input

function reset_keyboard {
  setxkbmap -layout us -option

function change_to_keyboard_cz {
  setxkbmap -layout us,cz -option grp:win_space_toggle

function change_to_keyboard_cz_ucw {
  setxkbmap -layout us,cz -variant ,ucw -option grp:caps_switch

function change_to_keyboard_compose {
  setxkbmap -option compose:caps
alias kb-compose='change_to_keyboard_compose'
alias kb-cz='change_to_keyboard_cz'
alias kb-cz-ucw='change_to_keyboard_cz_ucw'
alias kb-query='setxkbmap -query'