Skip to content

Keyboard stays in English (QWERTY) despite system language set to French (AZERTY) #15655

Description

@Chevalerie42

Batocera build version

42

Your architecture

RPI 4

Your Graphic Processor Unit(s) (GPU)

integrated

Issue description

Hello,

I am using a Raspberry Pi 4 with a fresh Batocera installation.
Being located in France, I set the system language to French.
In France, we use an AZERTY keyboard layout.
Unfortunately, Batocera's system settings do not apply and the keyboard remains in QWERTY.

I correctly edited the configuration file /userdata/system/batocera.conf :

system.language=fr_FR
system.kblayout=fr
system.kbvariant=azerty
system.timezone=Europe/Paris

After extensive research, I noticed that the file /etc/sway/config contains the following variable:

Set keyboard layout based on environment variables set (default US)

input * {
    xkb_layout $XKB_LAYOUT
    xkb_variant $XKB_VARIANT
}

I traced the $XKB_LAYOUT reference to the file /etc/init.d/S26system :

ba_keyboard_lang() {
    settings_lang="$(/usr/bin/batocera-settings-get system.language || echo 'en_US')"
    settings_kb="$(/usr/bin/batocera-settings-get system.kblayout || echo 'us')"
    settings_kb_variant="$(/usr/bin/batocera-settings-get system.kbvariant || echo '')"
    if [ "$settings_kb" != "" ]; then
        loadkeys "$settings_kb" >> $log
    else
        keyboardmap=$(echo "$settings_lang" | cut -c1-2)
        if [ "$keyboardmap" != "" ]; then
            loadkeys "$keyboardmap" >> $log
        fi
    fi
    # Export variables for graphical sessions (Sway, Xorg)
    export XKB_LAYOUT="$settings_kb_layout"
    export XKB_VARIANT="$settings_kb_variant"
}

Two important observations:

  1. The command /usr/bin/batocera-settings-get system.kblayout correctly returns "fr" on my system.
  2. The layout value is stored in $settings_kb but XKB_LAYOUT is incorrectly assigned from $settings_kb_layout (note the extra "_layout" suffix) which does not exist and is always empty.

Note: even after removing the "_layout" suffix directly from the overlay partition, I did not see any improvement

We can confirm the keyboard is stuck in English:

WAYLAND_DISPLAY=wayland-1 swaymsg -t get_inputs | grep -A5 "keyboard|Keyboard"

Returns:

    "type": "keyboard",
    "repeat_delay": 600,
    "repeat_rate": 25,
    "xkb_layout_names": [
      "English (US)"
    ],
[ REDACTED ]

I executed the following commands as root (reproducible workaround):

LAYOUT=$(/usr/bin/batocera-settings-get system.kblayout)
VARIANT=$(/usr/bin/batocera-settings-get system.kbvariant)
mount -o remount,rw /boot
printf '#!/bin/bash\nsed -i "s/xkb_layout \\$XKB_LAYOUT/xkb_layout %s/" /etc/sway/config\nsed -i "s/xkb_variant \\$XKB_VARIANT/xkb_variant %s/" /etc/sway/config\n' "$LAYOUT" "$VARIANT" > /boot/boot-custom.sh
chmod +x /boot/boot-custom.sh
reboot

After reboot, the keyboard is now correctly set to the system language:

WAYLAND_DISPLAY=wayland-1 swaymsg -t get_inputs | grep -A5 "keyboard|Keyboard"

Returns:


    "type": "keyboard",
    "repeat_delay": 600,
    "repeat_rate": 25,
    "xkb_layout_names": [
      "French (AZERTY)"
    ],
[ REDACTED ] 

I hope this can help. Thank you for the great work on Batocera !

Best regards,

Chevalerie

Detailed reproduction steps

  1. Installe batocera
  2. change language to french
  3. test keymap AZERTY = QWERTY

Details of any attempts to fix this yourself

No response

Details of any modifications you have made to Batocera.

Logs and data

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions