3

I want to remap capslock to ctrl, I found the answer online:

setxkbmap -option ctrl:nocaps

I tried in shell, it works. Now I want to persist it, I found some online post says that I need to create ~/.Xkbmap file in my home directory. I followed that and put the above configuration in this file. But it doesn't work. After reboot, capslock is still capslock.

I dug a little deeper, in /etc/X11/xinit/xinitrc.common, I find this line: cat $xkbmap | xkbcomp - $DISPLAY ($xkbmap is set to $HOME/.Xkbmap)

Any idea why my Xkbmap not sourced? I'm on OpenSUSE 13.2, using LXDM.

  • 1
    It depends on what display manager you are using (xdm/gdm/kdm/...) and what the display manager exactly does to start the X server (it may not necessarily use xinit). – dirkt Jan 5 '17 at 6:58
  • As dirkt wrote, this depends on your display manager. Try adding to ~/.xsessionrc. – Stop ongoing harm to Monica Jan 5 '17 at 7:02
  • @janos, it doesn't work, I just tried. – Aaron Shen Jan 5 '17 at 7:05
  • @dirkt, it's lxdm. – Aaron Shen Jan 5 '17 at 7:15
  • Quick googling finds "LXDM also makes use of .Xresources, .Xkbmap, and .Xmodmap. See /etc/lxdm/Xsession for details on how LXDM uses system-wide and per-user configuration files to configure the session" (though that may be different for OpenSuse). I've never used lxdm, so I don't know how the config files work. Have a close look at them, and figure out how they work. – dirkt Jan 5 '17 at 10:04
2

The DM I used is not sourcing my configuration file. It seems different dm has different initialization process. They don't guarantee to source the files under your home directory.

If you don't mind, you can modify the configuration file directly under /etc/X11/, I don't know which particular file should be the most reasonable place to put keyboard setting. But it should be easy to do by some google search.

In my case, because I'm using i3 window manager, so I directly source my configuration file in i3 config file. And it's working fine.

0

As you mentioned, the command that is executed is cat $xkbmap | xkbcomp - $DISPLAY.

The ~/.Xkbmap file is not a shell script that is sourced or executed, instead it should be an xkbcomp configuration file. The man page of xkbcomp hopefully will have some indication on the format of these files.

Apparently, the file ~/.config/lxsession/LXDE-pi/autostart might contain commands that are run on startup, prefixed with an @ sign. Try adding @setxkbmap -option ctrl:nocaps to that file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.