xmonad - Showing active keyboard on status bar

xmonad is tiling X11 window manager written & configured in Haskell.

After installing & configuring xmonad to my taste I missed one little thing: showing currently active keyboard layout on top.

After googling around & trying out some shell scripts I found this little program in github called XKB-SWITCH.

It allows easily to set the keyboard layout & also programmatically query the currently active keyboard layout. I already have my xmonad configured to switch keyboard layout by holding down both Shift keys so I just needed to use this utility to query currently active layout.

It was just plain simple to integrate this little program with xmobar. Just add this line to your xmobar configuration, under the commands function:

Run Com "xkb-switch" [] "kb" 10

Now, restart xmonad (modm + q) and that’s it. Your current keyboard layout should now be sitting on the status bar.

Here is a screenshot of mine (the result is surrounded by red rectangle)!

Screenshot of mine