3

I've been trying to configure my laptop, so that the builtin keyboard is in portuguese and my usb keyboard is in english (international). I have been doing some research and got to a solution that works perfectly well when the usb keyboard is plugged in after the xorg server is started. In this situation both keyboards have their respective layouts. But if I start the xorg server with the usb keyboard plugged in, both keyboards end up with the english layout.

Right now my /etc/X11/xorg.conf.d/30-keyboard.conf is the following:

Section "InputClass"
    Identifier "system-keyboard"
    MatchIsKeyboard "on"
    MatchProduct "AT Translated Set 2 keyboard"
    Driver "evdev"
    Option "XkbModel" "abnt2"
    Option "XkbLayout" "br"
EndSection

Section "InputClass"
    Identifier "usb-keyboard"
    MatchIsKeyboard "on"
    MatchProduct "Evision RGB Keyboard"
    Driver "evdev"
    Option "XkbModel" "pc104"
    Option "XkbLayout" "us"
    Option "XkbVariant" "altgr-intl"
EndSection

I really don't understand why it works well when I start the xorg server and then plug in the usb keyboard, but it doesn't work when I start the xorg server with the usb keyboard already plugged in.

I have tried breaking the config in 2 separate files 30-system-keyboard.conf and 40-usb-keyboard.conf so that one config is loaded afther the other one, but the result is the same.

Can someone please help me fix this, so that it works in all situations?

Setting the layouts via setxkbmap -device ID doesn't work because the IDs change.

1
  • My situation is similar but in the oppisite direction: I‌ want all keyboards I might attach to the laptop have a specific layout (de), but only the laptop's internal keyboard should have another layout (us). I have created first a configuration that matches all keyboards and sets layout de, and later a configuration that matches the AT Translated Set 2 keyboard and sets layout us. Commented Jul 7, 2023 at 12:21

1 Answer 1

0

I had a similar need that I could solve with an udev rule in /etc/udev/rules.d/70-keyboard.rules:

ACTION!="add|change", GOTO="keyboard_end"
SUBSYSTEM!="input", GOTO="keyboard_end"
KERNEL!="event*", GOTO="keyboard_end"

ENV{ID_INPUT_KEY}=="?*", DRIVERS=="usb", ATTRS{idVendor}=="413c", ATTRS{idProduct}=="2003", ENV{XKBMODEL}="pc105", ENV{XKBLAYOUT}="fr", ENV{XKBVARIANT}="oss", ENV{XKBOPTIONS}="nbsp:level3n,lv3:ralt_switch,compose:menu,terminate:ctrl_alt_bksp"

LABEL="keyboard_end"

It works fine when the keyboard is plugged before X is started.

You’ll have to duplicate the main line, replace the idVendor and idProduct values with those of your keyboards and XKBMODEL, XKBLAYOUT, XKBVARIANT and XKBOPTIONS parameters with the values that match the mapping you want to use.

You must log in to answer this question.

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