Comment 68 for bug 1875062

Revision history for this message
Benjamin Drung (bdrung) wrote (last edit ): Re: [20.04] Keyboard layout not enabled immediately during installation when typing username/password

Workaround
==========

Used jammy-desktop-amd64.iso from 2022-04-05.

* Install Welcome -> Try Ubuntu (keep English as language)
* Add your keyboard layout, e.g. by opening a terminal and run:
```
gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'de+neo'), ('xkb', 'us'), ('xkb', 'au'), ('xkb', 'cm'), ('xkb', 'gb')]"
```
* Then select your language in the GNOME indicator
* Start the installation:
```
ubiquity --debug gtk_ui
```
* Welcome -> Continue (keep English as language)
* Keyboard Layout -> Change to German (Neo 2) -> Continue
* Updates and other software -> Continue
* Installation type -> select what you want -> Install now
* Where are you? -> Continue
* Open a terminal and run:
```
sudo udevadm trigger
```

After the udevadm command, the keyboard layout in the installer is still the same (Neo 2 in my case).

First (failing) draft to fix the problem
========================================

I changed ubiquity (see 0001-Set-GNOME-keyboard-layout-v2.patch) to add the selected keyboard layout to org.gnome.desktop.input-sources sources.

Used jammy-desktop-amd64.iso from 2022-04-05.

* Install Welcome -> Try Ubuntu (keep English as language)
* Applied 0001-Set-GNOME-keyboard-layout-v2.patch to /usr/lib/ubiquity/plugins/ubi-console-setup.py
* Open a terminal and watch settings:
```
watch gsettings get org.gnome.desktop.input-sources sources
```
* Start installer in debug mode in second terminal:
```
ubiquity --debug gtk_ui
```
* Welcome -> Continue (keep English as language)
* Keyboard Layout -> Change to German (Neo 2) -> Continue

The watch command in the first terminal shows the new entries:

```
[('xkb', 'de+neo'), ('xkb', 'de'), ('xkb', 'us'), ('xkb', 'au'), ('xkb', 'cm'), ('xkb', 'gb')]
```

The strange and unexpected behavior is that the new entries do not appear in the GNOME keyboard indicator (and neither in "gnome-control-center keyboard").

Log output:

```
ubuntu@ubuntu:~$ grep "###" /var/log/installer/debug
Apr 6 16:39:52 ubiquity: ### org.gnome.desktop.input-sources sources = [('xkb', 'us'), ('xkb', 'au'), ('xkb', 'cm'), ('xkb', 'gb')]
Apr 6 16:39:52 ubiquity: ### Keyboard layout ('xkb', 'us') already in GNOME input sources: [('xkb', 'us'), ('xkb', 'au'), ('xkb', 'cm'), ('xkb', 'gb')]
Apr 6 16:39:59 ubiquity: ### org.gnome.desktop.input-sources sources = [('xkb', 'us'), ('xkb', 'au'), ('xkb', 'cm'), ('xkb', 'gb')]
Apr 6 16:39:59 ubiquity: ### Calling: gsettings set org.gnome.desktop.input-sources sources [('xkb', 'de'), ('xkb', 'us'), ('xkb', 'au'), ('xkb', 'cm'), ('xkb', 'gb')]
Apr 6 16:40:52 ubiquity: ### org.gnome.desktop.input-sources sources = [('xkb', 'de'), ('xkb', 'us'), ('xkb', 'au'), ('xkb', 'cm'), ('xkb', 'gb')]
Apr 6 16:40:52 ubiquity: ### Calling: gsettings set org.gnome.desktop.input-sources sources [('xkb', 'de+neo'), ('xkb', 'de'), ('xkb', 'us'), ('xkb', 'au'), ('xkb', 'cm'), ('xkb', 'gb')]
Apr 6 16:40:57 ubiquity: ### org.gnome.desktop.input-sources sources = [('xkb', 'de+neo'), ('xkb', 'de'), ('xkb', 'us'), ('xkb', 'au'), ('xkb', 'cm'), ('xkb', 'gb')]
Apr 6 16:40:57 ubiquity: ### Keyboard layout ('xkb', 'de+neo') already in GNOME input sources: [('xkb', 'de+neo'), ('xkb', 'de'), ('xkb', 'us'), ('xkb', 'au'), ('xkb', 'cm'), ('xkb', 'gb')]
```

Next steps
==========

* Figure out which commands are run by "udevadm trigger". Find the code that changes the keyboard layout.

* Figure out why there is a discrepancy between org.gnome.desktop.input-sources sources and the GNOME keyboard applet.