You are not logged in.

#1 2017-09-06 13:22:11

esonn
Member
From: Austria
Registered: 2015-10-01
Posts: 61

[SOLVED] XFCE + i3-gaps: No way to make setxkbmap/xmodmap permanent

I'm using a German keyboard layout (de, pc105, nodeadkeys) which works fine using XFCE on top of i3-gaps as WM. However, I'm used to mapping the CapsLock key to act as additional Escape (Vim-user here) for a decade now, no way to go back.

Executing either of the following commands work well:

xmodmap -e "clear Lock" -e "keysym Caps_Lock = Escape"
setxkbmap -option "caps:escape"

However, when I remove the notebook from the docking station and put it back, this mapping setting becomes lost. Note: I have uninstalled xfce4-xkb-plugin all along and removed configs, since this seems to be an error source for many similar problems according to countless posts on such matters.

What I furiously tried:

(1) Set /etc/X11/xorg.conf.d/00-keyboard.conf
...using

Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "de"
        Option "XkbModel" "pc105"
        Option "XkbVariant" "de_nodeadkeys"
        Option "XkbOptions" "caps:escape"
EndSection

Works, until laptop is removed from docking station. When I set the keyboard layout in XFCE settings to "Use system defaults" and re-enter laptop to dock, both layout and Caps-mapping is lost (layout becomes American); when I configure a German layout in XFCE settings, the layout remains German but Caps-mapping is lost nevertheless.

I also configured the mapping on various other locations which work fine on initial start, but not after undocking/docking (e.g. in .xinitrc, .Xmodmap, .config/i3/config).

(2) Use /etc/acpi/handler.sh to execute xmodmap on re-dock

        case "$4" in
            00004011)
                logger "acpi/handler.sh: Laptop undocked"
                ;;
            00004010)
                logger "acpi/handler.sh: Laptop docked"
                DISPLAY=:0.0
                export DISPLAY
                /bin/su eso -c "sleep 3; /usr/bin/xmodmap /home/eso/.xmodmaprc" &
                #/bin/su eso -c "sleep 3; setxkbmap -option "caps:escape" -display :0.0" &

I tried both, xmodmap and setxkbmap with various changes (with/without su, sleep, DISPLAY settings, full paths, ...), none worked. The logger lines are executed correctly. I then tried writing to a temporary file on re-dock event, and use a script interactively running in a urxvt shell to respond on changes to that file using inotify, but although no xmodmap/setxkbmap errors appeared, the CapsLock mapping was not set.

(3) Going low-level: /etc/udev/hwdb.d/90-custom-keyboard.hwdb
As mentioned in the Wiki, changing this mapping should also be doable on kernel-level, so I created the file mentioned above containing:

evdev:atkbd:dmi:bvn*:bvr*:bd*:svn*:pn*:pvr*
 KEYBOARD_KEY_3a=esc

Worked well, but only for the built-in keyboard and not for the USB keyboard I primarily use when the laptop is in dock. I tried various device-strings according to https://wiki.archlinux.org/index.php/Ma … o_keycodes, which should allow specifically targeting my USB keyboard (original Lenovo ThinkPad Compact USB keyboard) without success.

(4) Reading XFCE source-code
In

xfce4-settings/xfsettingsd/keyboard-layout.c

a function xfce_keyboard_layout_helper_process_xmodmap() exists, which checks if a .Xmodmap file exists in the user's home directory, and if so, executes xmodmap with the data contained therein. This probably would work, but it is only executed when actually changing keyboard settings, and not when docking/undocking (which I checked enabling xfsettingsd in non-daemonized debug mode).

(5) Tricking XFCE
When defining a non-system-default keyboard layout in XFCE settings, it is written to an XML config file which looks like that:

~/.config/xfce4/xfconf/xfce-perchannel-xml/keyboard-layout.xml:
-----------
<?xml version="1.0" encoding="UTF-8"?>

<channel name="keyboard-layout" version="1.0">
  <property name="Default" type="empty">
    <property name="XkbDisable" type="bool" value="true"/>
    <property name="XkbLayout" type="string" value="at"/>
    <property name="XkbVariant" type="string" value="nodeadkeys"/>
  </property>
</channel>

I tried to add another property node to reflect XkbOptions like that (as seen in e.g. https://github.com/iflowfor8hours/dotfi … layout.xml):

 <property name="XkbOptions" type="empty">
      <property name="Group" type="string" value="caps:escape"/>
</property>

What can I say, that doesn't work either.

I really enjoy my setup. but this is so massively annoying, I don't find words to describe it. Beloved Arch community, you are my last hope now.

Last edited by esonn (2017-09-07 14:10:52)


Anyone who quotes me in their sig is an idiot. -- Rusty Russell

Offline

#2 2017-09-06 18:02:50

stupidus
Member
Registered: 2012-02-27
Posts: 124

Re: [SOLVED] XFCE + i3-gaps: No way to make setxkbmap/xmodmap permanent

I have a similar problem with the same setxkbmap option. However, I don't have a dock, and the problem is only with external USB keyboards, the laptop keyboard usually works fine. For me the problem seems to appear when disconnecting/reconnecting the external keyboard. It might also be related to suspend/resume, but I am not sure. Anyway, as a workaround I restart i3 via "i3-msg restart" (I have a keybind for that). In my i3 config I use "exec_always" with setxkbmap. But I am using pure i3-gaps without XFCE, so I don't know if that would cause issues with the i3 restart.

Offline

#3 2017-09-07 13:51:02

esonn
Member
From: Austria
Registered: 2015-10-01
Posts: 61

Re: [SOLVED] XFCE + i3-gaps: No way to make setxkbmap/xmodmap permanent

I can confirm a similar behavior when un- and replugging only the USB keyboard. Interestingly enough, both - the German layout as well as the Capslock/Escape mapping - are reset (to default US keyboard layout), not only the XkbOptions for the latter.


Anyone who quotes me in their sig is an idiot. -- Rusty Russell

Offline

#4 2017-09-07 14:10:22

esonn
Member
From: Austria
Registered: 2015-10-01
Posts: 61

Re: [SOLVED] XFCE + i3-gaps: No way to make setxkbmap/xmodmap permanent

Got it working with variant (3), on kernel level by creating a file in /etc/udev/hwdb.d/. As the wiki says here, it is seemingly imperative to get the necessary scancodes by using the evtest tool rather than traditional methods like scankey.

Correct file content in /etc/udev/hwdb.d/ is:

evdev:input:b0003v17EFp6047*   # verfied with lenovo slim usb keyboard
 KEYBOARD_KEY_70039=esc

Anyone who quotes me in their sig is an idiot. -- Rusty Russell

Offline

Board footer

Powered by FluxBB