One can use
loadkeys
command to set appropriate keyboard layout. My question is how can I check the currently selected layout (in the console mode)?
Command:
localectl status
Output:
System Locale: LANG=en_US.UTF-8
VC Keymap: us
X11 Layout: us
You can check keyboard file for keyboard layout information...
nano /etc/default/keyboard
OUTPUT:
# KEYBOARD CONFIGURATION FILE
# Consult the keyboard(5) manual page.
XKBMODEL="pc105"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS=""
BACKSPACE="guess"
Value of XKBLAYOUT is the layout of keyboard. Change it to another possible value and reboot the machine to take effects.
This is a workaround but...it works
xset -q | grep LED | awk '{ print $10 }')
the output is a number made of 8 digits corresponding to.. something related to the layout (in my case 00000000 for gb and 00001000 for it). Care to the fact that this number changes if you have CAPS LOCK enabled (the same number but +1).
If you want it as a string you can edit my simple script.
#!/bin/sh
COMMAND=$(xset -q | grep LED | awk '{ print $10 }')
case "$COMMAND" in
"00000000"|"00000001") LAYOUT="uk" ;;
"00001000"|"00001001") LAYOUT="it" ;;
*) LAYOUT="??" ;;
esac
echo $LAYOUT
As referenced by the man page for setfont, you could use showconsolefont. As referenced by the manpage for loadkeys, you could use dumpkeys.
This is way with one direction.
loadkeys modify kernel keyboard driver's translation table by loadind keyboard keymap file.
If nobody issue loadkeys you can check /etc/rc.d/rc.keymap file for loaded keymap.
You can check content of kernel keyboard driver's translation table using dumpkeys. There are no tool to find from which keymap file data was loaded into table.