36

Is there a utility that allows to graphically display the current keyboard layout?

This can be useful, for example, when writing in a foreign language and having the physical keyboard only indicating the local language (positioning of symbols, etc.). I would like to get a display similar to the following: enter image description here

landroni
  • 10,288
  • 12
  • 30
  • 48

9 Answers9

21

From the command line: gkbd-keyboard-display -l <layout>.

gkbd-keyboard-display screenshot

To see what your installed keyboards are (for example to find the layout code to use in the command above) use setxkbmap -query.

Colonel Panic
  • 453
  • 2
  • 8
  • 19
gessel
  • 321
  • 2
  • 5
  • 1
    IMHO this is the nicest diagram, although it doesn't distinguish dead keys in any way https://gitlab.gnome.org/GNOME/libgnomekbd/-/issues/10 – Colonel Panic Jan 29 '22 at 23:19
  • 1
    `setxkbmap -query` shows the layout and the variant. The variant needs to be added in brackets: `gkbd-keyboard-display -l `. – cipricus Jun 25 '22 at 07:35
  • As said in a comment by @ToDo under [here](https://askubuntu.com/a/459997/925128), numerical order can be used like so (example for the third kb in the list): `gkbd-keyboard-display -g 3`. – cipricus Jun 25 '22 at 07:58
17

xkeycaps seems to do what you want, if I understand you correctly.

enter image description here

Colonel Panic
  • 453
  • 2
  • 8
  • 19
Jenny D
  • 13,022
  • 3
  • 38
  • 54
  • Indeed! I had it installed, but forgot the command. – landroni Jan 30 '14 at 09:22
  • 7
    This will not work (= display the current mapping visually as a picture), if the user has made changes to the keysyms with e.g. `xmodmap`. If you mouseover the changed key(s), the keysym line in the top half of the `xkeycaps` is updated correctly though. I am researching the same question, but I have made lots of changes with xmodmap. So I was looking for a nice means to display current key mappings too. – Alex Stragies Nov 20 '16 at 20:45
10

Selecting the current layout with gkbd-keyboard-display is possible like so:

#! /usr/bin/env fish
set layout (setxkbmap -query | grep layout | tr -s ' ' | cut -d ' ' -f2)
set variant (setxkbmap -query | grep variant | tr -s ' ' | cut -d ' ' -f2)
gkbd-keyboard-display -l $layout\t$variant

Or, similarly:

#! /bin/bash
layout=`setxkbmap -query | grep layout | tr -s ' ' | cut -d ' ' -f2`
variant=`setxkbmap -query | grep variant | tr -s ' ' | cut -d ' ' -f2`
gkbd-keyboard-display -l ${layout}$'\t'${variant}
Raphael
  • 2,035
  • 1
  • 21
  • 34
7

You can use xkbprint to print the current layout.

For example to print the current layout as PDF use

xkbprint -color "${DISPLAY}" - |\
    ps2pdf - > current_keyboard_layout.pdf

which produces:

xkbprint result

Flow
  • 819
  • 1
  • 11
  • 23
  • It seems this prints the *image* of main/default keyboard layout, in my case US. There is *written* info about the other keyboards (e.g. in my case, `Group 1 Layout: pc+us+fr:2+us(intl):3+ro(std):4+inet(evdev)+level3(switch)+level3(ralt_alt)+ctrl(swap_rwin_rctl) Generic 104−key PC`), but if I select French keyboard, for example, it prints the image of the US keyboard anyway. – cipricus Jun 25 '22 at 07:06
3

Manjaro Settings Manager > Keyboard Settings

It looks like this:

Keyboard Settings in Manjaro Settings Manager

2

In Gnome that is available already, although not for the currently selected keyboard (that simple feature seams universally absent). As shown here:

enter image description here

In Plasma and other desktops that seem to lack this feature, based on the previous answers, we can create desktop launchers for each keyboard in our keyboard layouts list. I use 4 layouts, so I have a list like so in Plasma:

enter image description here

In order to show my Romanian layout, I have created the file ~/.local/share/applications/show-keyboard-layout_ro.desktop with these contents:

[Desktop Entry]
Type=Application
Name=Show keyboard layout ROMANIAN
Comment=
Icon=/home/cip/.icons/RO-Romania-Flag-icon.png
Exec=gkbd-keyboard-display -g 4
Terminal=false
Categories=Utility

4 stands for the fact that Romanian is 4th in that list. Different ones can be created.

To launch it I type in the applications launcher:

enter image description here

And it pops up:

enter image description here

cipricus
  • 1,386
  • 13
  • 42
1

To integrate this feature nicely in the Gnome environment, create the following file:

~/.local/share/applications/show-keyboard-layout.desktop

With the following content:

[Desktop Entry]
Type=Application
Name=Show keyboard layout
Comment=
Icon=/usr/share/icons/Yaru/256x256/devices/input-keyboard.png
Exec=gkbd-keyboard-display -l "us(altgr-intl)"
Terminal=false
Categories=Utility

Press ALT-F2, and enter ‘r’ to restart the Gnome desktop if you use X11, or restart the session if you use Wayland.

To open the layout window, press the Super key (e.g. Windows key), and then enter the first letters of “Show keyboard layout” until the proper entry is shown. Finally, press enter.

The layout shown is hard coded. You can query the keyboard currently used with the following command and adapt the .desktop file accordingly using the following command line:

setxkbmap -query
ocroquette
  • 132
  • 7
  • This is not specific to Gnome, it creates an "application" launcher. But it shouldn't be called "Show keyboard layout", but "Show US-AltGr-International layout". It doesn't show your *currently selected* layout, but the one *specified* in command. Looking up the help of `gkbd-keyboard-display` there isn't a way to show the already selected layout, we have to specify the layout or the number: `-g, --group=group number (1, 2, 3, 4) Group to display -l, --layout=layout (with optional variant) Layout to display`. So, e.g. for second kb, `gkbd-keyboard-display -g 2` works too. – cipricus Jun 25 '22 at 08:09
  • Considering my previous comment: a good idea would be to select for icon not the generic input-keyboard one (because it will not show any input, but the specified one), and instead use a national-flag icon for the specific language, like those found [here](https://iconarchive.com/search?q=france). – cipricus Jun 25 '22 at 08:18
  • In fact in Gnome (if that's your thing) you have that already, you have an option to see an image of each of your kb-layouts: images [here](https://superuser.com/q/1293956/1039759). – cipricus Jun 25 '22 at 08:51
0

Current keyboard layout chart onliner (based on Raphael's answer but using awk and localectl):

gkbd-keyboard-display -l $(localectl status | awk '/X11 Layout/ {print $3}')$'\t'$(localectl status | awk '/X11 Variant/ {print $3}')

On an alias, using string literal syntax:

alias current_keyboard_layout_chart=$'gkbd-keyboard-display -l $(localectl status | awk \'/X11 Layout/ {print $3}\')$\'\t\'$(localectl status | awk \'/X11 Variant/ {print $3}\')'
Pablo A
  • 2,307
  • 1
  • 22
  • 34
  • For some reason it only shows me the default US kb even when I switch to French for example. It should show whatever keyboard is selected not the locale/default one. When I manually write the desired keyboard (listed with `setxkbmap -query` and then `gkbd-keyboard-display -l `) it works. – cipricus Jun 25 '22 at 07:28
0

Run tastenbrett. For me, unlike gkbd-keyboard-display and xkeycaps, this shows me dead keys as well as what keys do when pressing alt.

tastenbrett is the tool that is called when you preview a keyboard layout from the Kubuntu System Settings.

dremodaris
  • 101
  • 2