13

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)?

peterh
  • 2,782
Ringger81
  • 1,397
  • 3
  • 13
  • 28

7 Answers7

9

Command:

localectl status

Output:

  System Locale: LANG=en_US.UTF-8
  VC Keymap: us
  X11 Layout: us
8

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.

3

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
bummi
  • 1,725
  • 4
  • 16
  • 28
2

I think you are looking for the command dumpkeys

1

As referenced by the man page for setfont, you could use showconsolefont. As referenced by the manpage for loadkeys, you could use dumpkeys.

Seth
  • 9,393
0

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.

bormant
  • 71
-1

You can use this script to find out which keyboard layout you are using:

#!/bin/bash
var=" $(xset -q | grep -i "led mask" | grep -o "....1...")"
if [ -z $var ]
then
    echo "Using the first layout"
else
    echo "Using the second one"
fi
jous
  • 817
Mahdi
  • 1