You are not logged in.

#1 2023-06-02 12:32:07

Dizzar
Member
Registered: 2023-04-03
Posts: 10

[Solved] Switching keyboard layout using XKBOptions does not work

I have two keyboard layouts: us and ru. My keyboard is configured in /etc/X11/xorg.conf.d/00-keyboard.conf  as

Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Driver "evdev"
        Option "XkbLayout" "us,ru"
        Option "XkbModel" "evdev"
        Option "XkbVariant" ","
        Option "XkbOptions" "grp:rctrl_toggle,ctrl:swapcaps,myswap:tab_win"
EndSection

myswap is just a little file that I made that swaps Tab and Super_L buttons that I placed at /usr/share/X11/xkb/symbols/myswap and looks like this:

// Swap tab and super
partial modifier_keys   
xkb_symbols "tab_win" {
    key <TAB> {[ Super_L ]};
    key <LWIN> {[ Tab ]};
    modifier_map Mod4 { <TAB> };
};

Everything works, except switching layouts on right control press. In fact, I tried to use other switches such as alt+shift but they didn't work either. After a restart, running 'setxkbmap -query -verbose 10' outputs the following:

Setting verbose level to 10
locale is C
Trying to load rules file ./rules/evdev...
Trying to load rules file /usr/share/X11/xkb/rules/evdev...
Success.
Applied rules from evdev:
rules:      evdev
model:      pc105
layout:     us
Trying to build keymap using the following components:
keycodes:   evdev+aliases(qwerty)
types:      complete
compat:     complete
symbols:    pc+us+inet(evdev)
geometry:   pc(pc105)
rules:      evdev
model:      pc105
layout:     us

I kinda do not even see my configured layouts there, only 'us'. I use i3wm.

Last edited by Dizzar (2023-06-04 10:31:03)

Offline

#2 2023-06-02 13:27:07

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,740

Re: [Solved] Switching keyboard layout using XKBOptions does not work

Please post your xorg log.
Do your i3 config/session scripts maybe override the server config w/ setxkbmap?

Offline

#3 2023-06-03 04:59:24

Dizzar
Member
Registered: 2023-04-03
Posts: 10

Re: [Solved] Switching keyboard layout using XKBOptions does not work

seth wrote:

Please post your xorg log.

https://0x0.st/HbV4.0.log

seth wrote:

Do your i3 config/session scripts maybe override the server config w/ setxkbmap?

I double checked and the only reference to setxkbmap is commented out.

Now, I want it be known that adding the line

myswap:tab_win = +myswap(tab_win)

to /usr/share/X11/xkb/rules/evdev seemed to have fixed the issue, but from what is written in that file it is not the best of ideas to modify it by hand. Additionaly, after removing that line from the aforementioned file, myswap no longer seems to work (it worked before I added that rule to evdev rules), but layout switching now works???

Offline

#4 2023-06-03 06:26:51

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,740

Re: [Solved] Switching keyboard layout using XKBOptions does not work

Fyi

        Driver "evdev"
[     7.468] (II) LoadModule: "evdev"
[     7.468] (WW) Warning, couldn't open module evdev
[     7.468] (EE) Failed to load module "evdev" (module does not exist, 0)
[     7.468] (EE) No input driver matching `evdev'

from what is written in that file it is not the best of ideas to modify it by hand

It's gonna be replaced w/ the next xkeyboard-config udpate, try using /usr/share/X11/xkb/rules/evdev-C

Offline

#5 2023-06-03 07:33:23

Dizzar
Member
Registered: 2023-04-03
Posts: 10

Re: [Solved] Switching keyboard layout using XKBOptions does not work

seth wrote:

Failed to load module "evdev" (module does not exist, 0)

I have rewritten the config as follows (generated this using systemd-localed with the command 'localectl set-x11-keymap us,ru pc105 , grp:rctrl_toggle,ctrl:swapcaps,myswap:tab_win'):

Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "us,ru"
        Option "XkbModel" "pc105"
        Option "XkbVariant" ","
        Option "XkbOptions" "grp:rctrl_toggle,ctrl:swapcaps,myswap:tab_win"
EndSection

But that doesnt seem to make a difference (the error had disappeared though) (xorg log from this run - https://0x0.st/HbW8.0.log) < - fixed url
Switching layouts with right control worked, but not my swapping tab with left super rule.

seth wrote:

try using /usr/share/X11/xkb/rules/evdev-C

I put the 'myswap:tab_win = +myswap(tab_win)' rule in this file and indeed the tab swapping rule now works. Howewher, switching layouts with right control stopped working. Didnt change the xorg config from the previous run.
Here is the log from this run - https://0x0.st/HbWK.0.log

Out of curiosity, I removed the rule from evdev-C file (it is now an empty file) and rebooted my system. Nothing seems to have changed (I did check the original evdev rule file - my rule is not present there). Tab swapping works, right control layout switch doesnt. I am at loss. Xorg log - https://0x0.st/HbWB.0.log

Last edited by Dizzar (2023-06-03 07:39:19)

Offline

#6 2023-06-03 07:41:15

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,740

Re: [Solved] Switching keyboard layout using XKBOptions does not work

setxkbmap -print -query -verbose 10

Offline

#7 2023-06-03 07:42:58

Dizzar
Member
Registered: 2023-04-03
Posts: 10

Re: [Solved] Switching keyboard layout using XKBOptions does not work

seth wrote:
setxkbmap -print -query -verbose 10
Setting verbose level to 10
locale is C
Trying to load rules file ./rules/evdev...
Trying to load rules file /usr/share/X11/xkb/rules/evdev...
Success.
Applied rules from evdev:
rules:      evdev
model:      pc105
layout:     us,ru
options:    myswap:tab_win,grp:rctrl_toggle,ctrl:swapcaps
Trying to build keymap using the following components:
xkb_keymap {
};
rules:      evdev
model:      pc105
layout:     us,ru
options:    myswap:tab_win,grp:rctrl_toggle,ctrl:swapcaps

Offline

#8 2023-06-03 15:08:19

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,740

Re: [Solved] Switching keyboard layout using XKBOptions does not work

This is w/

Tab swapping works, right control layout switch doesnt. I am at loss.

?
Can you

xdotool key ISO_Next_Group

What does "xev -event keyboard" report for the right control key?

Offline

#9 2023-06-03 23:06:42

Dizzar
Member
Registered: 2023-04-03
Posts: 10

Re: [Solved] Switching keyboard layout using XKBOptions does not work

seth wrote:

This is w/

Tab swapping works, right control layout switch doesnt. I am at loss.

?

Yes

seth wrote:

Can you

xdotool key ISO_Next_Group

Does not output anything (nothing happened, either)

seth wrote:

What does "xev -event keyboard" report for the right control key?

KeyPress event, serial 28, synthetic NO, window 0x1a00001,
    root 0x1e3, subw 0x0, time 195065, (211,739), root:(1177,751),
    state 0x10, keycode 105 (keysym 0xffe4, Control_R), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 28, synthetic NO, window 0x1a00001,
    root 0x1e3, subw 0x0, time 196209, (211,739), root:(1177,751),
    state 0x14, keycode 105 (keysym 0xffe4, Control_R), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

Pressed and released the key

Last edited by Dizzar (2023-06-04 03:46:49)

Offline

#10 2023-06-04 05:40:52

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,740

Re: [Solved] Switching keyboard layout using XKBOptions does not work

So the toggle isn't applied though the option is added - did you copy /usr/share/X11/xkb/rules/evdevt to /usr/share/X11/xkb/rules/evdev-C and edit that or did you just add your own config to /usr/share/X11/xkb/rules/evdev-C ?

Offline

#11 2023-06-04 10:24:36

Dizzar
Member
Registered: 2023-04-03
Posts: 10

Re: [Solved] Switching keyboard layout using XKBOptions does not work

seth wrote:

So the toggle isn't applied though the option is added - did you copy /usr/share/X11/xkb/rules/evdevt to /usr/share/X11/xkb/rules/evdev-C and edit that or did you just add your own config to /usr/share/X11/xkb/rules/evdev-C ?

I simply created the file and added my rule there. Should I have copied the evdev file to evdev-C?

Update: I copied the evdev file to evdev-C and added my rule there. Everything (ctrl swap, my own tab swap and layout switching) now works. The 'setxkbmap -print -query -verbose 10' command now outputs this:

Setting verbose level to 10
locale is C
Trying to load rules file ./rules/evdev...
Trying to load rules file /usr/share/X11/xkb/rules/evdev...
Success.
Applied rules from evdev:
rules:      evdev
model:      pc105
layout:     us,ru
options:    myswap:tab_win,grp:rctrl_toggle,ctrl:swapcaps
Trying to build keymap using the following components:
keycodes:   evdev+aliases(qwerty)
types:      complete
compat:     complete
symbols:    pc+us+ru:2+inet(evdev)+myswap(tab_win)+group(rctrl_toggle)+ctrl(swapcaps)
geometry:   pc(pc105)
xkb_keymap {
	xkb_keycodes  { include "evdev+aliases(qwerty)"	};
	xkb_types     { include "complete"	};
	xkb_compat    { include "complete"	};
	xkb_symbols   { include "pc+us+ru:2+inet(evdev)+myswap(tab_win)+group(rctrl_toggle)+ctrl(swapcaps)"	};
	xkb_geometry  { include "pc(pc105)"	};
};
rules:      evdev
model:      pc105
layout:     us,ru
options:    myswap:tab_win,grp:rctrl_toggle,ctrl:swapcaps

Which is what I would expect it to look like. Thank you for your help.

Last edited by Dizzar (2023-06-04 10:30:31)

Offline

Board footer

Powered by FluxBB