1

I'd like to have simple instructions of how to permanently and consistently set up a custom keyboard layout configuration for all of these user interfaces in a standard Ubuntu desktop installation with GNOME/Wayland (as of version 23.10):

  • Linux console
  • Login screen (GDM)
  • Wayland session* (GNOME Shell, Mutter and XWayland)

(*) both system-wide and user-specific

  1. Where do I put my custom keyboard layout file(s) and in which format?

  2. What is the most straightforward way to change these settings?


Note: I know something about XKB, IM, localectl, the keyboard-configuration package, etc. However, in practice it is a big mess with scarce documentation. Even the Debian wiki page about the topic explains a lot, but doesn't give clear instructions.

1

2 Answers 2

1

I've figured it out by myself. Here is the easiest step-by-step solution:

1. Make a copy of the keyboard layout/variant that you want to customize

I wanted to customize the Portuguese (Brazil, Dvorak) layout. Therefore I made a copy of the Brazilian Portuguese XKB layout file:

$ cp /usr/share/X11/xkb/symbols/br br-custom

2. Edit the layout file as you wish

Edit the copy of the layout file. You may follow the instructions in this question's answers to create your custom layout: What are the steps needed to create a new keyboard layout?

3. Install the customized layout file

First, backup the original layout file:

$ sudo mv /usr/share/X11/xkb/symbols/{br,br.bak} 

Then install the file that you have just edited:

$ sudo cp br-curstom /usr/share/X11/xkb/symbols/br

Note: in the commands above, substitute the br part by the name of the layout you are customizing.

4. Verify that the modified layout is working

Open the Settings application and go to Keyboard > Input Sources.

If the layout variant you want to use is not in the list of keyboard layouts, search and add it:

enter image description here

Then, click the three dots button at the right of the customized layout's name and select View Keyboard Layout:

enter image description here

If the layout file is OK, a graphical representation of it should show up. If it doesn't, you may have introduced a syntax error when editing it or maybe included a layout component with the wrong name. You'll need to fix it before continuing.

5. Test the customized layout

After selecting the new layout in Settings, it will be set up for your user's desktop session. Open a text editor and check that your customizations are working accordingly. If it doesn't work as expected, edit the layout file again and reinstall it until it's right for you. Be careful to not overwrite the backed up version.

6. Apply the keyboard layout to the login screen and Linux console

When you are 100% sure that the customized layout is working, you may apply it to the login screen and the Linux console (the pseudo-terminals that are accessed by pressing Ctrl + Alt + F2 through Ctrl + Alt + F6).

Run this command and select the keyboard layout/variant you've just modified:

$ sudo dpkg-reconfigure keyboard-configuration

enter image description here

Finally, restart the PC and check if the customized layout was applied to the login screen as well.

1

To complement the accepted answer, I have found that if you add a new variant in the file /usr/share/X11/xkb/symbols/br, it does not appear in the list in GNOME settings. However, after adding it in /usr/share/X11/xkb/rules/evdev.xml and /usr/share/X11/xkb/rules/evdev.lst, you can simply close the GNOME settings and reopen it and it will appear there. For the system tray to also show it, you need to restart though.

You must log in to answer this question.

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