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