Get current keyboard layout in Linux. Based on the code of Filip Krikava.
> xlayout
Full name: Italian
Layout name: it
You may need to install some packages for compilation:
apt install gcc x11proto-dev
Compile:
gcc -I/usr/include xlayout.c -lX11 -lxkbfile -o xlayout
Move it to a directory where your shell searces for executables. For instance:
echo $PATH
mv xlayout ~/bin/
Get layout short name:
xlayout | grep Layout | cut -d' ' -f3