26 November 2014

Changing keyboard layout in system console

The post is about configuring a Unicode keyboard layout for the system console on Gentoo. However, the steps should be similar on other systems.

Enable Unicode in /etc/rc.conf:

unicode="yes"

Install a font for UTF-8 consoles:

# emerge -av media-fonts/terminus-font

Change /etc/conf.d/consolefont:

consolefont=LatArCyrHeb-16
# consolefont="ter-v16b"
consoletranslation=""
Make sure that /etc/init.d/consolefont is enabled:
# rc-update add consolefont boot

Set default console keymap in /etc/conf.d/keymaps:

keymap="us"

Add /etc/init.d/keymaps to the boot run level:
# rc-update add keymaps boot

Configure the shell to send switch-to-unicode escape sequence at each login. For Bash add the following to your ~/.bash_profile:

if test -t 1 -a -t 2 ; then
        echo -n -e '\033%G'
fi

To make the switch to Unicode global for all users the above-mentioned snippet should be added to /etc/profile.

Reboot the system. Now Unicode should be available on all system console logins.

To load different keyboard layout use the loadkeys command (which is shipped with sys-apps/kbd package):

# loadkeys /usr/share/keymaps/{YOUR_ARCH}/{PATH_TO_KEYMAP}
For instance, to load Russian Qwerty layout for i386 (will work on amd64):
# loadkeys /usr/share/keymaps/i386/qwerty/ru.map.gz

One might want to make a shortcut for this. Use Ctrl-Shift shortcut for switching between the keymaps.

No comments :

Post a Comment