Solved Wrong keyboard map in X

Starting fvwm-crystal with startx into a virtualbox freebsd machine. I noticed the following symptoms:

The keyboard works fine into the main consoles. /etc/rc.conf:
Code:
clear_tmp_enable="YES"
hostname="TuxBsd"
#keymap="ch-fr.acc.kbd
keymap="ch-fr.kbd"
ifconfig_em0="dhcp"
sshd_enable="YES"
moused_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
zfs_enable="YES"
vboxguest_service="YES"
vbox_service="YES"
That show the keycodes are correctly passed to virtualbox into the gentoo linux host, and that virtualbox is correctly passing them to the machine. Among other things that works fine is the shell history with the Up and Down arrow keys of the keyboard.

Into X and fvwm-crystal, I get the correct language and even the French accented keys are working, but some other keys are screwed, which interfere with fwm-crystal keybindings and made the shell history to not work anymore. /usr/local/etc/X11/xorg.conf.d/00-keyboard.conf
Code:
Section "InputClass"
        Identifier "keyboard-all"
        MatchIsKeyboard "on"
#       MatchDevicePath "/dev/input/event*"
#       Driver "libinput"
#       Driver "xorg"
        Option "XkbLayout "ch"
#       Option "XkbModel" "logiultrax"
        Option "XkbModel" "pc105"
        Option "XkbVariant "fr"
        Options "XkbOptions "terminate:ctrl_alt_bksp,keypad:pointerkeys"
EndSection
Code:
% setxkbmap -query
rules:       evdev
model:       pc105
layout:      ch
variant:     fr
options:     terminate:ctrl_alt_bksp,keypad:pointerkeys

In the gentoo host, I get the same setxkbmap query. This is why I changed the model to pc105 when the device is a logitech UltraX. That change nothing.
xev in gentoo recognize the up and down array keys and return Up and Down, when in freebsd, the down key is correct and return a Down keysym, but for the up key, It gives no keysym but:
Code:
KeymapNotify event, serial 36, synthetic NO, window 0x0,
    keys:   236 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
            0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
Same issue with the "Page Up" and "Page Down" keys, Page Down gives Next and work fine, when Page Up get no keysym, but get assigned by some bad magic to fvwm-crystal keybing that toggle the active window into its titlebar. Some thing into the main console, both keys are working fine. Any advice will be appreciated.
 
Last edited:
Can you try removing the XkbVariant line in your keyboard configuration file and replace the XkbLayout line with the line below with the extra 'fr'?
Code:
Section "InputClass"
    Identifier "keyboard-all"
    MatchIsKeyboard "on"
    Option "XkbLayout "ch,fr"
    Options "XkbModel" "pc105"
    Options "XkbOptions "terminate:ctrl_alt_bksp,keypad:pointerkeys"
EndSection
All of the examples that I have seen either have a blank i.e. default XkbVariant value or they are set to a form of physical keyboard layout like 'nodeadkeys,dvorak' or 'altgr-intl,qwerty' etc rather than a language code.
 
It was a typo into my first message in Options "XkbModel" "pc105". It must be no 's' to Option. I corrected it. It was right into the file.
A thing have changed: into /etc/rc.conf, it is now keymap="ch-fr.acc.kbd" that is commented out.

I try to do some new user accounts, a testsh and a testbash. With them, after login into the tty, the keyboard is just fine. Then I follow chapter 25 of the handbook about localization and put into ~/.login_conf:

me:\
:charset=UTF-8:\
:lang=fr_ch.UTF-8:

and run cap_mkdb ~/.login_conf. After that, the keyboard stopped to work well in both accounts. I get the correct language map (keys like q and z are at the right place), composed keys like [ and { are fine, but the same keys as simple keys à and è (the accented keys) doesn't work anymore, they are dead.

So with the testbash account, I reversed the changes, removed the file generated by cap_mkdb. But with or without that, the issue with fvwm remain the same.
 
It was a typo into ~/.login_conf:

:lang=fr_ch.UTF-8:
when it should be fr_CH.UTF-8. But that changed nothing. I get an answer from the hacker mailing list, mac_mkdb should be run only against /etc/login.conf. But that too, as I already did it and removed its generated file from $HOME, changed nothing.
 
I found a way to get ride of that keyboard issue, but it is a workaround, not a real fix.

After installing lightdm and adding it into /etc/rc.conf, I can start fvwm-crystal from it and that keyboard issue don't appear. But that doesn't tell me what I can do to fix it with startx.
 
FYI: I have /usr/local/etc/X11/xorg.conf.d/input.conf for Japanese 106 (aka OADG106) keyboard and working for various DEs and WMs on X11.

Note that (you may already know, though) keyboard configurations of console (CUI) and X11 are independent and set both of them.

Not 100% sure this applies currently or not, as I first encountered this before X11 on FreeBSD ports swtiched from XF86 to xorg.

At least, XF86 always considered keyboard as US101 even if I've configured keyboard for console (as there was not yet vt, it was sc) for jp.106.kbd (jp.kbd for vt).

Code:
Section "InputClass"
    Identifier        "Keyboard Defaults"
    MatchIsKeyboard        "on"
    MatchDevicePath        "/dev/input/event*"
    Driver            "libinput"
    Option            "XkbRules" "evdev"
    Option            "XkbModel" "jp106"
    Option            "XkbLayout" "jp"
EndSection
 
It may not make any difference when using startx, but when you're specifying the keymap name in /etc/rc.conf, it's recommended not to include the .kbd suffix.
Done. No change.
However, can you post the contents of your ~/.xinitrc file?
Code:
#!/bin/sh

xrandr --output default --mode "1600x900"
xrdb ~/.Xdefaults

FVWMCRYSTAL_DEBUG="1"
export FVWMCRYSTAL_DEBUG

if [ -f .errors.fvwm-crystal ]; then
    mv -f .errors.fvwm-crystal .errors.fvwm-crystal.old
fi

exec /usr/local/bin/fvwm-crystal 2>.errors.fvwm-crystal
#exec dbus-launch --exit-with-x11 ck-launch-session /usr/local/bin/fvwm-crystal 2>.errors.fvwm-crystal
#exec fvwm3 2>.errors.fvwm
I try to comment out the xrandr and xrdb lines, or to startx with exec dbus-launch or fvwm3 with its default config, but nothing helped.
 
Done. No change.

Code:
#!/bin/sh

xrandr --output default --mode "1600x900"
xrdb ~/.Xdefaults

FVWMCRYSTAL_DEBUG="1"
export FVWMCRYSTAL_DEBUG

if [ -f .errors.fvwm-crystal ]; then
    mv -f .errors.fvwm-crystal .errors.fvwm-crystal.old
fi

exec /usr/local/bin/fvwm-crystal 2>.errors.fvwm-crystal
#exec dbus-launch --exit-with-x11 ck-launch-session /usr/local/bin/fvwm-crystal 2>.errors.fvwm-crystal
#exec fvwm3 2>.errors.fvwm
I try to comment out the xrandr and xrdb lines, or to startx with exec dbus-launch or fvwm3 with its default config, but nothing helped.

FYI:
My ~/.xinitrc, removing old commented out remnants, IME configs and anything which would not affect WMs/DEs.

Code:
## Default stuff from /usr/local/etc/X11/xinit/xinitrc
userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/usr/local/etc/X11/xinit/.Xresources
sysmodmap=/usr/local/etc/X11/xinit/.Xmodmap


if [ -f $sysresources ]; then
    xrdb -merge $sysresources
fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f "$userresources" ]; then
    xrdb -merge "$userresources"
fi

if [ -f "$usermodmap" ]; then
    xmodmap "$usermodmap"
fi

if [ -d /usr/local/etc/X11/xinit/xinitrc.d ] ; then
    for f in /usr/local/etc/X11/xinit/xinitrc.d/?* ; do
        [ -x "$f" ] && . "$f"
    done
    unset f
fi

## End default stuff.


## Set LANG environment variable
#
export LANG="${LANG:-ja_JP.UTF-8}"


## Support arrow keys to work with libinput
export XKB_DEFAULT_RULES=evdev


## Select preferred WindowManager
## Examples below.
#
# export WINDOWMANAGER=Cinnamon
export WINDOWMANAGER=Mate
# export WINDOWMANAGER=XFce4
# export WINDOWMANAGER=Gnome
# export WINDOWMANAGER=Lumina
# export WINDOWMANAGER=KDE
# export WINDOWMANAGER=KDE6
# export WINDOWMANAGER=WindowMaker


if [ -d /compat/linux/proc/0 ]
then
  echo linprocfs is already mounted.
else
  mount /compat/linux/proc
fi


## Internatial configuration
#
echo '*international: true' | xrdb -merge
echo '*fontSet: k14, r14' | xrdb -merge


## Load X application configuration file
#
[ -f ~/.Xdefaults ] && xrdb -merge ~/.Xdefaults


## Load X keymap configuration file
#
[ -f ~/.Xmodmap ] && xmodmap ~/.Xmodmap


## Choice of Window Manager
#
if [ -z "${WINDOWMANAGER}" ]
then
    if [ -x /usr/local/bin/mate-session ]
    then
        export WINDOWMANAGER=Mate
    elif [ -x /usr/local/bin/gnome-session-cinnamon ]
    then
        export WINDOWMANAGER=Cinnamon
    elif [ -x /usr/local/bin/gnome-session ]
    then
        export WINDOWMANAGER=Gnome
    elif [ -x /usr/local/bin/startxfce4 ]
    then
        export WINDOWMANAGER=XFce4
    elif [ -x /usr/local/bin/Lumina-DE ]
    then
        export WINDOWMANAGER=Lumina
    elif [ -x /usr/local/bin/startkde ]
    then
        export WINDOWMANAGER=KDE
    elif [ -x /usr/local/bin/wmaker ]
    then
        export WINDOWMANAGER=WindowMaker
    fi
fi


## Window Manager startup
#
case "${WINDOWMANAGER}" in
[Cc][Ii][Nn][Nn][Aa][Mm][Oo][Nn])
    exec cinnamon-session
#    exec ck-launch-session cinnamon-session
    ;;
[Mm][Aa][Tt][Ee])
    LIBOVERLAY_SCROLLBAR=0
    exec dbus-launch --exit-with-session ck-launch-session mate-session
#    exec ck-launch-session dbus-launch mate-session
#    exec ck-launch-session mate-session
#    exec mate-session
    ;;
[Gg][Nn][Oo][Mm][Ee])
#    exec gnome-session
    exec ck-launch-session dbus-launch gnome-session
    ;;
[Ll][Uu][Mm][Ii][Nn][Aa])
#    exec ck-launch-session dbus-launch Lumina-DE
    exec ck-launch-session dbus-launch start-lumina-desktop
    ;;
[Kk][Dd][Ee]6)
#    exec startkde
    exec ck-launch-session startplasma6-x11
    ;;
[Kk][Dd][Ee])
#    exec startkde
    exec ck-launch-session startplasma-x11
    ;;
[Xx][Ff][Cc][Ee]4)
#    export GSMARTCONTROL_SU=pinentry-gtk-2
#    exec startxfce4
#    exec ck-launch-session startxfce4
    exec startxfce4 --with-ck-launch
    ;;
[Ww][Ii][Nn][Dd][Oo][Ww][Mm][Aa][Kk][Ee][Rr]|wmaker)
    [ ! -d ~/GNUstep ] && wmaker.inst
    [ -f ~/.gtkrc-2.0-wmaker ] && export GTK2_RC_FILES=~/.gtkrc-2.0-wmaker
    exec /usr/local/bin/wmaker
    ;;
*)
    exec "${WINDOWMANAGER:-twm}"
    ;;
esac

With this ~/.xinitrc and keyboard config in my comment #10, I can start, for example, XFce4 by commenting out export WINDOWMANAGER=Mate line and uncommenting # export WINDOWMANAGER=XFce4 line.
 
With this ~/.xinitrc and keyboard config in my comment #10, I can start, for example, XFce4 by commenting out export WINDOWMANAGER=Mate line and uncommenting # export WINDOWMANAGER=XFce4 line.
Thanks, but I am not interested to run another wm/desktop than fvwm-crystal and, in case of issue, fvwm, that to see if I can reproduce it with a minimum fvwm config. And it is the case here with both fvwm2 and fvwm3.

If I want to sheet and see how other desktops works, I run them into a docker, so I am 100% sure they will not mess with my user preferences. Before docker, I used Xephyr for that, it is even a Xephyr menu into fvwm-crystal. But docker provide a very good system isolation, when Xephyr provide no isolation at all. I hate to loose my settings, it was the main reason why I begun to use fvwm-crystal and I never looked back.

I also begun to use X with X11, but with modern Xorg and as I saw into the handbook, most of the xinit config is done from the system, and it is just when something doesn't works as wanted that we need to use /usr/local/etc/X11/xorg.conf.d, with a few exceptions like the xrdb stuff for the Xlib software. Including for these Xlib software, freebsd provide a very good default config.
 
With this ~/.xinitrc and keyboard config in my comment #10, I can start, for example, XFce4 by commenting out export WINDOWMANAGER=Mate line and uncommenting # export WINDOWMANAGER=XFce4 line.
A few years ago, I done a .xinitrc with something like that:
Code:
echo "Choose a letter and press Enter to start the corresponding wm/de:"
echo "c : fvwm-crystal"
echo "f : fvwm"
echo "k : kde"
...
read Desktop
case $Desktop in
    c)
        exec fvwm-crystal
        ;;
    f)
        exec fvwm
        ;;
    k)
        exec dbus-launch ...
        ;;
    *)
        echo "Sorry, I don't understand"
        ;;
  esac
It is also possible to put stuffs from the echo to the esac into a while loop, that to make it to start again after the *) case and after a wm/de quit.
 
If I run ardour in fvwm-crystal, both use a lot of keybindings using the Meta key, Alt_L+<key> by default on most systems, and the fvwm-crystal keybindings take over the ardour keybindings, which is very annoying when using ardour. That also concern other software. For that, I added a preference that let the user to set these modifier keys like Alt_L. As example, One can replace Alt_L by Win_L. fvwm-crystal will use that setting, but the other software will continue to use the default Meta key.

Which makes me to think that maybe, some system keybindings for the shells are taking over the fvwm keybindings at Init. Fvwm have a StartFunction separated in 3, Init that is executed only at fvwm Init, Restart that is executed only at fvwm Restart, and Start that is executed at fvwm Init and Restart. Fvwm also use an internal shell (sh by default as with fvwm-crystal) for its commands like Exec (that send commands to the outside world via the shell) and Piperead (that interpret the output of commands as fvwm config).
 
Which makes me to think that maybe, some system keybindings for the shells are taking over the fvwm keybindings at Init.
Which do you mean with system key bindings for the shells, CUI console (before starting X11/Wayland), or terminal emulators on X11/Wayland?

For the former, it shouldn't affect X11/Wayland, as keyboard drivers of both vt/sc (CUI console) and X/Wayland handles keyboards by "hardware scan codes" and maps them into "character codes" by themselves.

For the latter, possibly affects. As DEs/WMs/Apps on X11/Wayland "basically" accepts "character codes" from keyboard driver of X11/Wayland and maps functionalities onto it, if I recall correctly.
 
All I have in my ~/.xinitrc related to keymaps is setxkbmap gb and it works correctly.
Can you try adding the following at the top of your ~/.xinitrc file and see if that makes a difference?
setxkbmap -layout ch,fr -model pc105 -option terminate:ctrl_alt_bksp,keypad:pointerkeys
Failing that, can you just leave the -layout option in by removing the -model and -option parts of the command to see if that helps?
 
setxkbmap -layout ch,fr -model pc105 -option terminate:ctrl_alt_bksp,keypad:pointerkeys
That is the way to go, thanks if finally work fine.
I removed the xkbd.conf file into /usr/local/etc/X11/xorg.conf.d, but into your example the ch,fr is to switch between 2 different layouts. After different try and retry and more search, I was able to find the right syntax:
setxkbmap -layout 'ch(fr)' -model pc105 -option terminate:ctrl_alt_bksp,keypad:pointerkeys
Note the single quotes around the layout and the ().
 
Back
Top