You are not logged in.

#1 2015-05-17 04:50:15

Bobyl
Member
Registered: 2010-02-10
Posts: 18

Different layouts on different keyboards in X

Hi,

I'm having troubles configuring my keyboards to get different layouts under X.

What I have
Two keyboards connected through USB: a wireless Logitech and a wired typematrix.

What I would like
Different layouts on the two keyboards: french layout with bepo variant on the typematrix and french layout with latin9 variant en the logitech.

What is working
I've used xinput list to get both keyboards device ids. The following script, run after WM startup, does what I want:

#!/bin/zsh
setxkbmap -device 11 fr -variant latin9
setxkbmap -device 13 fr -variant bepo

However, I'd really like to automatize the process.

What does not work
I've tried automatically running the above script at KDE startup or at SDDM startup, both keyboards end up using the same variant (bepo for what it's worth). It looks like the "device" option is not taken into account.

I've then tried asigning the layouts in xorg config files. First with input classes to match my keyboards:

Section "InputClass"
    Identifier         "Keyboard Layout bepo"
    MatchIsKeyboard    "yes"
    MatchProduct       "TypeMatrix.com USB Keyboard"
    MatchDevicePath    "/dev/input/event*"
    Option             "XkbLayout"  "fr"
    Option             "XkbVariant" "bepo"
EndSection

Section "InputClass"
    Identifier         "Keyboard Layout latin9"
    MatchIsKeyboard    "yes"
    MatchProduct       "Logitech USB Receiver"
    MatchDevicePath    "/dev/input/event*"
    Option             "XkbLayout"  "fr"
    Option             "XkbVariant" "latin9"
EndSection

Both keyboards end up in latin9 variant. I assumed that the Match statements were linked by a logical AND but it looks like it's a logical OR and both keyboards are matched on /dev/input/event*.

And then with the "ancient" input device method:

Section "InputDevice"
        Identifier      "logitech"
        Driver          "evdev"
        Option          "Device"        "/dev/input/by-id/usb-Logitech_USB_Receiver-event-kbd"
        Option          "xkb_rules" "evdev"
        Option          "xkb_model" "evdev"
        Option          "xkb_layout" "fr"
        Option          "GrabDevice" "on" # prevent send event to other X-servers
        Option          "XkbVariant" "latin9"
EndSection

Section "InputDevice"
        Identifier      "typematrix"
        Driver          "evdev"
        Option          "Device"        "/dev/input/by-id/usb-TypeMatrix.com_USB_Keyboard-event-kbd"
        Option          "xkb_rules" "evdev"
        Option          "xkb_model" "evdev"
        Option          "xkb_layout" "fr"
        Option          "GrabDevice" "on" # prevent send event to other X-servers
        Option          "XkbVariant" "bepo"
EndSection

All this is a bit annoying since I'm trying to set up a multiseat configuration. If anyone has an idea...

Last edited by Bobyl (2015-05-17 12:50:11)

Offline

#2 2015-05-17 11:32:52

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: Different layouts on different keyboards in X


Jin, Jîyan, Azadî

Offline

#3 2015-05-17 12:30:07

Bobyl
Member
Registered: 2010-02-10
Posts: 18

Re: Different layouts on different keyboards in X

Thanks for your suggestion.

I disabled layout setting in xorg.conf.d/10-keyboard.conf and tried using an udev rule to run my script on keyboard plugging:

ACTION=="add", ATTRS{idVendor}=="1e54", ATTRS{idProduct}=="2030", RUN+="/home/jc/kb.sh", OWNER="jc"

The script is actually called, but keyboard settings seem to be superseded by KDE. I ran journalctl while unplugging/plugging the keyboard back and:

kcm_keyboard: Fetched layout groups from X server:         layouts: ("us")         variants: ("")

So it seems that upon connection of a new device, KDE  uses the settings set in System Settings -> Input and overwrite any previous keyboard setting. And since it is impossible to configure different keyboards in KDE, I'm stuck with manual running of my script at each startup/wake.

Offline

#4 2015-05-17 12:56:52

Bobyl
Member
Registered: 2010-02-10
Posts: 18

Re: Different layouts on different keyboards in X

I went back to trying to configure the keymaps directly in xorg.conf.d/10-keyboard.conf.

When looking at the logs, my rules are definitely corrects since I can see:

cat /var/log/Xorg.0.log |grep InputClass 

[ 10878.171] (**) Logitech USB Receiver: Applying InputClass "evdev keyboard catchall"
[ 10878.171] (**) Logitech USB Receiver: Applying InputClass "Keyboard Layout latin9"
[ 10878.197] (**) Logitech USB Receiver: Applying InputClass "evdev pointer catchall"
[ 10878.197] (**) Logitech USB Receiver: Applying InputClass "evdev keyboard catchall"
[ 10878.197] (**) Logitech USB Receiver: Applying InputClass "Keyboard Layout latin9"
[ 10878.201] (**) TypeMatrix.com USB Keyboard: Applying InputClass "evdev keyboard catchall"
[ 10878.201] (**) TypeMatrix.com USB Keyboard: Applying InputClass "Keyboard Layout bepo"
[ 10878.229] (**) TypeMatrix.com USB Keyboard: Applying InputClass "evdev keyboard catchall"
[ 10878.229] (**) TypeMatrix.com USB Keyboard: Applying InputClass "Keyboard Layout bepo"

Correct input classes are applied to each device. I however still end up with both keyboard using the bepo layout...

Offline

#5 2021-08-27 08:49:19

doragasu
Member
Registered: 2012-03-03
Posts: 160

Re: Different layouts on different keyboards in X

Maybe a bit late, but I'll leave this here just in case somebody has the same problem. I wanted to be able to switch between "us" and "us intl" for the internal laptop keyboard, but be able to switch between "es", "us" and "us intl" layouts on external keyboards. This configuration worked for me, basically I define a config for the laptop keyboard (AT Translated Set 2 keyboard, you can get the model name using e.g. xinput command) and another config for all other keyboards:

Section "InputClass"
        Identifier "evdev keyboard catchall"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
        Option "XkbLayout" "es,us,us"
		Option "XkbVariant" ",,intl"
		Option "XkbOptions" "grp:lalt_lshift_toggle"
EndSection
Section "InputClass"
        Identifier "evdev internal keyboard"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*"
	MatchProduct "AT Translated Set 2 keyboard"
        Driver "evdev"
        Option "XkbLayout" "us,us"
		Option "XkbVariant" ",intl"
		Option "XkbOptions" "grp:lalt_lshift_toggle"
EndSection

About why it was not working for the creator of this post, I do not know, but I suspect that maybe the desktop environment was applying its own config and overriding xorg settings.

Offline

#6 2021-08-27 12:25:31

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,648

Re: Different layouts on different keyboards in X

Closing this ancient topic.

Offline

Board footer

Powered by FluxBB