40

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

10 Answers 10

25

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.

4
  • 1
    IMHO this is the nicest diagram, although it doesn't distinguish dead keys in any way gitlab.gnome.org/GNOME/libgnomekbd/-/issues/10 Commented Jan 29, 2022 at 23:19
  • 1
    setxkbmap -query shows the layout and the variant. The variant needs to be added in brackets: gkbd-keyboard-display -l <layout(variant)>.
    – cipricus
    Commented Jun 25, 2022 at 7:35
  • As said in a comment by @ToDo under here, numerical order can be used like so (example for the third kb in the list): gkbd-keyboard-display -g 3.
    – cipricus
    Commented Jun 25, 2022 at 7:58
  • After a recent fresh Debian install with KDE, it seems I have no default configured layout. So I could not find the actual mapping using that command (for which I had to install the gkbd-capplet package, by the way). Nevertheless, tastenbrett did the trick, in my case, as suggested in that answer
    – Olivier
    Commented Oct 20, 2023 at 9:29
17

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

enter image description here

3
  • Indeed! I had it installed, but forgot the command.
    – landroni
    Commented Jan 30, 2014 at 9:22
  • 8
    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. Commented Nov 20, 2016 at 20:45
  • In my case, even after selecting the correct French one, the highlighted keys were not the correct ones, as I was trying to figure out the mapping.
    – Olivier
    Commented Oct 20, 2023 at 9:19
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}
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

1
  • 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
    Commented Jun 25, 2022 at 7:06
4

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

1
  • 1
    Lifesaver. Curious this is missing in KDE.
    – Topknot
    Commented Dec 15, 2022 at 23:41
3

Manjaro Settings Manager > Keyboard Settings

It looks like this:

Keyboard Settings in Manjaro Settings Manager

2
  • I think this is a Gnome-only interface.
    – cipricus
    Commented Jun 25, 2022 at 6:42
  • Using KDE at that time 🤔 Commented Dec 18, 2022 at 23:17
2

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.

1
  • Using KDE, this is the killer app, which shows the actual mapping, whatever the system configuration. Thanks! (just in case, tastenbrett is available in the plasma-desktop package)
    – Olivier
    Commented Oct 20, 2023 at 9:30
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
3
  • 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
    Commented Jun 25, 2022 at 8: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.
    – cipricus
    Commented Jun 25, 2022 at 8: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.
    – cipricus
    Commented Jun 25, 2022 at 8:51
1

Tecla replaces gkbd-keyboard-display on gnome nowadays ( e.g. this issue ). You can use it this way:

$ tecla fr
$ tecla gb
1
  • Nice, but with a total lack of documentation
    – Milind R
    Commented Jun 19 at 9:18
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}\')'
1
  • 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 <layout(variant)>) it works.
    – cipricus
    Commented Jun 25, 2022 at 7:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .