Solved Keyboard layout keeps getting messed up

Hi all,

I've got a strange issue. My keyboard layout is set to "gb" which works fine most of the time. However at seemingly random moments the keyboard layout changes. For example the "up arrow" key becomes the "print" key, and other keys stop working.

I then manually run "setxkbmap gb" and it works again, up until it once again messes up. Below you can see the before and after moments:

Code:
#$ setxkbmap -print
xkb_keymap {
    xkb_keycodes  { include "evdev+aliases(qwerty)"    };
    xkb_types     { include "complete"    };
    xkb_compat    { include "complete"    };
    xkb_symbols   { include "pc+gb+inet(evdev)"    };
    xkb_geometry  { include "pc(pc105)"    };
};
#$ setxkbmap -print
xkb_keymap {
    xkb_keycodes  { include "evdev+aliases(qwerty)"    };
    xkb_types     { include "complete"    };
    xkb_compat    { include "complete"    };
    xkb_symbols   { include "pc+us+inet(evdev)"    };
    xkb_geometry  { include "pc(pc105)"    };
};

Looking at the above it seems to set itself to "us" layout, however if I manually set "us" layout the arrow keys work fine, so it says it is "us" but the layout is not really "us".

Has anyone seen this kind of behaviour before? My Xorg.conf does not have "us" layout at all, so I don't know why it keeps being set to that. It also seems to be random. Sometimes it works for days, other times the layout gets messed up multiple times an hour.
 
use xmodmap file to save option.
Thanks, I tried dumping my configuration using "xmodmap -pke > ~/.Xmodmap", and then applying but the same problem persists.

The layout works for a while then randomly gets re-mapped. For example the the problem of "Arrow Up" key becoming the "Print Screen" key still occurs.

So far I've not found a solution to this :( The best I've some up with is the kludge of running "setxkbmap gb" in cron every single minute of the day, so that if the layout does get messed up, it corrects within a minute at the latest.
 
My Xorg.conf does not have "us" layout at all, so I don't know why it keeps being set to that
When you install FreeBSD, the installer defaults to a standard "US" keyboard map. If you haven't permanently set your keyboard layout to be "GB" then it might default back to "US" at times.

There are several places to define your GB keymap:
In your ~/.xinitrc file (if you're using one).
In your /etc/rc.conf file.
In an X configuration file (i.e. /etc/X11/xorg.conf.d/00-keyboard.conf).
Which one are you currently using?
 
When you install FreeBSD, the installer defaults to a standard "US" keyboard map. If you haven't permanently set your keyboard layout to be "GB" then it might default back to "US" at times.
Yes, however I set the keyboard to GB when I installed the OS

There are several places to define your GB keymap:
In your ~/.xinitrc file (if you're using one).
Yes I am using one, and it is defined there
In your /etc/rc.conf file.
It is defined here too
In an X configuration file (i.e. /etc/X11/xorg.conf.d/00-keyboard.conf).
Yep, its defined in my Xorg configuration as well
Which one are you currently using?
Turns out, all three :-)


Thing is, the "US" layout does not result in the "Up Arrow" key becoming "Print Screen". If I run "setxkbmap us" the arrow keys still work fine. There are only minute differences between GB and US layout.
 
Another option, I would look at your WM/DE configuration. Maybe there is something? What window manager or desktop environment do you use?
 
Can you post all the three relevant sections of code please? Might be something non-obvious like a typo etc. Thanks

Code:
# xinitrc:
setxkbmap -layout gb

#xorg.conf
        Option "XkbRules" "xorg"
        Option "XkbModel" "pc105"
        Option "XkbLayout" "gb"

#rc.conf
keymap="uk.iso"
 
Your ~/.xinitrc looks correct. Mine is just setxkbmap gb, but it isn't incorrect to use -layout, it's the default. However, your entry in /etc/rc.conf might be wrong depending on which virtual terminal console driver you're using. If you're using vt (use this command to check: sysctl -a | grep kern.vty) then you need the UK keymap defined in /usr/share/vt/keymaps/uk.kbd and not the UK keymap defined in /usr/share/syscons/keymaps/uk.iso.kbd (which you're currently using) which is for the syscons console driver. So, hopefully all you should need to do is change the line to keymap="uk". If that still doesn't fix things, post back and we'll keep digging.
 
I'm using Windowmaker
The one with which I don't have any experience. :) I would look there, maybe there is somewhere set US keyboard layout?
Another option could be setting in an application, but that isn't too common (if any).

Something was come to my mind, when the keyboard layout switch happens, is there something in the Xorg.log?
 
The one with which I don't have any experience. :) I would look there, maybe there is somewhere set US keyboard layout?
Another option could be setting in an application, but that isn't too common (if any).

Something was come to my mind, when the keyboard layout switch happens, is there something in the Xorg.log?
Of course it had to be :-)

From what I've searched in the preferences there is no ability to set keymappings from within WM. This post seems to indicate that windowmaker relies on XKB, so just setting the value in my Xorg should be enough

Something was come to my mind, when the keyboard layout switch happens, is there something in the Xorg.log?

There doesn't seem to be, grepping for "Keyboard" nets only the initial start up on the first minute of Xorg execution:

Code:
# Xorg.0.log
[    49.034] (**) |-->Input Device "Keyboard0"
[    49.046] (WW) Disabling Keyboard0
[    51.358] (II) Initializing extension XKEYBOARD
[    51.482] (II) config/udev: Adding input device System keyboard multiplexer (/dev/input/event0)
[    51.482] (**) System keyboard multiplexer: Applying InputClass "Evdev keyboard"
[    51.482] (**) System keyboard multiplexer: Applying InputClass "libinput keyboard catchall"
[    51.504] (II) Using input driver 'libinput' for 'System keyboard multiplexer'
[    51.504] (**) System keyboard multiplexer: always reports core events
[    51.521] (II) event0  - System keyboard multiplexer: is tagged by udev as: Keyboard
[    51.521] (II) event0  - System keyboard multiplexer: device is a keyboard
[    51.523] (II) event0  - System keyboard multiplexer: device removed
[    51.523] (II) XINPUT: Adding extended input device "System keyboard multiplexer" (type: KEYBOARD, id 6)
[    51.542] (II) event0  - System keyboard multiplexer: is tagged by udev as: Keyboard
[    51.543] (II) event0  - System keyboard multiplexer: device is a keyboard
[    51.552] (**) Power Button: Applying InputClass "Evdev keyboard"
[    51.552] (**) Power Button: Applying InputClass "libinput keyboard catchall"
[    51.553] (II) event2  - Power Button: is tagged by udev as: Keyboard
[    51.554] (II) event2  - Power Button: device is a keyboard
[    51.555] (II) XINPUT: Adding extended input device "Power Button" (type: KEYBOARD, id 8)
[    51.556] (II) event2  - Power Button: is tagged by udev as: Keyboard
[    51.557] (II) event2  - Power Button: device is a keyboard
[    51.558] (II) config/udev: Adding input device AT keyboard (/dev/input/event3)
[    51.558] (**) AT keyboard: Applying InputClass "Evdev keyboard"
[    51.558] (**) AT keyboard: Applying InputClass "libinput keyboard catchall"
[    51.558] (II) Using input driver 'libinput' for 'AT keyboard'
[    51.558] (**) AT keyboard: always reports core events
[    51.560] (II) event3  - AT keyboard: is tagged by udev as: Keyboard
[    51.560] (II) event3  - AT keyboard: device is a keyboard
[    51.563] (II) event3  - AT keyboard: device removed
[    51.563] (II) XINPUT: Adding extended input device "AT keyboard" (type: KEYBOARD, id 9)
[    51.565] (II) event3  - AT keyboard: is tagged by udev as: Keyboard
[    51.565] (II) event3  - AT keyboard: device is a keyboard
[    51.568] (**) vendor 0x046a product 0x0011: Applying InputClass "Evdev keyboard"
[    51.568] (**) vendor 0x046a product 0x0011: Applying InputClass "libinput keyboard catchall"
[    51.570] (II) event4  - vendor 0x046a product 0x0011, class 0/0, rev 2.00/1.00, addr 5: is tagged by udev as: Keyboard
[    51.570] (II) event4  - vendor 0x046a product 0x0011, class 0/0, rev 2.00/1.00, addr 5: device is a keyboard
[    51.572] (II) XINPUT: Adding extended input device "vendor 0x046a product 0x0011" (type: KEYBOARD, id 10)
[    51.574] (II) event4  - vendor 0x046a product 0x0011, class 0/0, rev 2.00/1.00, addr 5: is tagged by udev as: Keyboard
[    51.574] (II) event4  - vendor 0x046a product 0x0011, class 0/0, rev 2.00/1.00, addr 5: device is a keyboard
 
Your ~/.xinitrc looks correct. Mine is just setxkbmap gb, but it isn't incorrect to use -layout, it's the default. However, your entry in /etc/rc.conf might be wrong depending on which virtual terminal console driver you're using. If you're using vt (use this command to check: sysctl -a | grep kern.vty) then you need the UK keymap defined in /usr/share/vt/keymaps/uk.kbd and not the UK keymap defined in /usr/share/syscons/keymaps/uk.iso.kbd (which you're currently using) which is for the syscons console driver. So, hopefully all you should need to do is change the line to keymap="uk". If that still doesn't fix things, post back and we'll keep digging.
I checked and am using "vt" so my current setting is incorrect. I will try changing it and see what happens.

Note this issue seems to only occur in X, the console has generally been fine. Although I admit I don't spend much time in the console to notice random keymap changes.
 
Well, its been over a month since my last post, and since the change above it looks like the problem has gone. The keyboard config now only changes to "US" when I unplug and plug the keyboard in.

Still not sure why that happens as I would expect it to default to whatever is defined in Xorg by default (e.g. GB for me), but during normal use the keyboard does not go funny, so happy to mark this solved.

Thanks all for your help!
 
Back
Top