Permanent Xorg keyboard layout - XKB Configuration

Hi Folks,

after having read a lot of documentation including the official one provided by Xorg at: https://www.x.org/releases/X11R7.5/doc/input/XKB-Config.html I'm still not able to preserve the Italian (it) xkb xorg layout from being wiped out when I disconnect from a X session, and make it permanent.

The configuration file under /usr/local/etc/X11/xorg.conf.d is simply ignored by Xorg.
The same if I invoke "setxkbmap it" command via .xinitrc, it is ignored or not executed at all.

Screenshot from 2024-04-12 13-58-19.png


Only option is to manually configure the keyboard layout via: setxkbmap it, though it is only temporary, lasting only during the duration of the X session.

Any idea to sort this?

Thanks
 
Hi. I have configured it like this and it works. You can view this gist for xkboptions.
Code:
% cat /usr/local/etc/X11/xorg.conf.d/00-keyboard.conf
Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "us,tr"
        Option "XkbOptions" "grp:shift_caps_toggle"
EndSection
 
No luck unfortunately, my setting is even simpler than yours and it is simply ignored by Xorg
No clue what could be.

Code:
~ % cat /usr/local/etc/X11/xorg.conf.d/00-keyboard.conf
Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "it"
        Option "XkbModel"  "pc105"
EndSection
 
Do you have keymap set in /etc/rc.conf ? If you don't have it set, try setting it to it.kbd
Code:
% grep keymap /etc/defaults/rc.conf
keymap="NO"             # keymap in /usr/share/{syscons,vt}/keymaps/* (or NO).

% ls /usr/share/vt/keymaps/ | grep it
it.kbd
 
Here it is:

Code:
% cat /etc/rc.conf
clear_tmp_enable="YES"
hostname="freebsd-14-cde"
keymap="it.kbd"
ifconfig_vmx0="inet 10.29.38.8 netmask 255.255.255.0"
defaultrouter="10.29.38.241"
sshd_enable="YES"
moused_enable="YES"
ntpd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
zfs_enable="YES"
rpcbind_enable="YES"
inetd_enable="YES"
dtlogin_enable="YES"

That was selected at installation time, my problem is only during the X session.
In console mode the correct layout is properly mapped.

It would be even great if "setxkbmap it" could be executing during X bootup, I've put it in my .xinitrc file as well, but again, the command is ignored.

Code:
% setxkbmap -query
rules:      base
model:      pc105
layout:     it

This is after having set it manually via "setxkbmap it" command
 
I just added setxkbmap to my .xinitrc and it works. I didnt understand why it doesnt work for you.

Code:
% cat .xinitrc
slstatus &
dunst &
xrdb -load ~/.Xresources
feh --randomize --bg-scale ~/Pictures/
hydroxide serve &
picom &
setxkbmap it
exec dbus-launch --exit-with-session --sh-syntax dwm

Code:
% setxkbmap -query
rules:      evdev
model:      pc105
layout:     us,tr
options:    grp:shift_caps_toggle

I noticed one thing, there is base in your rules of query command but mine is evdev. May that be the issue?

Is there an app that you can control keyboard settings in your desktop environment?

Do you use a display manager?
 
That is per default.
Where can I find the xkb rule?

BTW:
Code:
~ % cat .xinitrc
setxkbmap it

One command only, totally ignored.
There's something I'm missing for sure.
Problem is the monitor.conf file settings worked setting up the proper resolution.
Mouse as well... only the keyboard is being ignored.
 
what desktop environment are you using for X11
it may be that you need to set the xkb options in your window manager config files

just checking are you connecting to a remote X session with ssh or is it a local X session
 
I'm using CDE and I already thought what you are stating.
However the xbk setting is set just before the CDE loading.
If a disable the CDE and I start X in basic mode the keyboard layout is already set.

I'm connected to a local session.
FreeBSD is running under VmWare.
I have the same issue with running FreeBSD in bare-metal though...
 
This is an excerpt of my /var/log/Xorg.0.log file:

Code:
[    18.662] (II) Using input driver 'kbd' for '<default keyboard>'
[    18.662] (**) Option "CoreKeyboard" "on"
[    18.662] (**) <default keyboard>: always reports core events
[    18.662] (**) <default keyboard>: always reports core events
[    18.662] (**) Option "Protocol" "standard"
[    18.662] (**) Option "XkbRules" "base"
[    18.662] (**) Option "XkbModel" "pc105"
[    18.662] (**) Option "XkbLayout" "us"

There you can see the setting is somehow set by default.
I've also tried to grep "XkbRules" over the whole filesystem and I found there is another configuration file here:

/usr/local/share/X11/xorg.conf.d/20-evdev-kbd.conf

totally ignored as well.
The loaded xkbrule is base indeed.
 
I sorted the issue out.

Needed to declare the keyboard as "InputDevice", specify the driver "xbd" and manually set the "XkbdRules" to "Xorg".
I guess it would work even with "base".

Simply declaring it with "InputClass" was not enough as Xorg overrides the user settings.

Hereafter is my configuration file as of now:

Code:
~ % more /etc/X11/xorg.conf.d/00-keyboard.conf
Section "InputDevice"
        Identifier "Keyboard0"
        Driver "kbd"
        Option "XkbRules" "xorg"
        Option "XkbModel" "pc105"
        Option "XkbLayout" "it"
EndSection


Code:
~ % setxkbmap -query
rules:      xorg
model:      pc105
layout:     it

I've also moved the base configuration directory from /usr/local/etc/X11 to /etc/X11.

Anyway, the configuration mechanism of Xorg is really a mess!
Multiple directories, nested parameters... if you don't pay attention you easily drive yourself around the bend.

Regarding why whichever command set into .xinitrc is merely ignored, I do not have any answer yet.
I'll do investigate on that.
 
I have the same problem, although this didn't solve it.

I just added this to /usr/local/etc/X11/xorg.conf.d/00-keyboard.conf:

Code:
Section "InputDevice"
        Identifier "Keyboard0"
        Driver "kbd"
        Option "XkbRules" "xorg"
        Option "XkbModel" "craft"
        Option "XkbLayout" "fi"
EndSection

If I run setxkbmap -query after reboot, I get the following:

Code:
rules:      evdev
model:      logicd
layout:     us

I have the Finnish keyboard set as the only layout in KDE but it always loads as US. Whenever I start Gnome, it loads the correct layout. Is there an SDDM configuration file somewhere where the US keyboard layout is loaded?

EDIT: Here's a thread about this problem I created before I noticed this thread. https://forums.freebsd.org/threads/kde-5-loads-wrong-keyboard-layout.93108/
 
Be aware KDE has it's own keyboard layout manager that overrides the predefined one run by Xorg. If you want to have the confirmation Xorg is properly getting the configuration you've made, disable KDE, run Xorg in standalone mode and check whether the keyboard responds properly.

CDE does not have its own keyboard layout management, it sits on top of the Xorg input device manager.

Everything looks working like a charm now with FreeBSD 14 and CDE... I feel quite satisfied :)
Now I'm ready to port everything to my little bare metal.

Screenshot from 2024-04-13 10-47-25.png
 
Back
Top