You are not logged in.

#1 2013-04-25 22:26:59

ccc1
Member
Registered: 2009-04-16
Posts: 111

[Solved] Strange Problem swapping Esc and Caps lock in X

Hi
i use xmodmap to swap esc and caps lock. my .xmodmaprc:

remove Lock = Caps_Lock
keycode	 9 = Caps_Lock
keycode 66 = Escape dead_diaeresis
add Lock = Caps_Lock

As login manager i use slim and everthing works as expected as long as i don't activate slim's autologin option. In this case pressing caps lock executes  caps lock and esc. The same happens if i start X from the console via startx. I have no clue why this happens. Anyone got an idea whats the problem?
More, maybe relevant info: i use dwm as window manager and xmodmap is executed in .xinitrc.
ccc1

Last edited by ccc1 (2014-04-26 08:19:55)

Offline

#2 2013-04-25 22:41:06

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [Solved] Strange Problem swapping Esc and Caps lock in X

I find that many of these types of common key switches are supported by xorg.conf.d configurations.  For example, I use my caps lock as a secondary "windows key" since that is the mod key for my i3 setup.  So I have this in /etc/X11/xorg.conf.d/10-evdev.conf

% cat /etc/X11/xorg.conf.d/00-keyboard.conf
<snip>
Section "InputClass"
        Identifier "evdev keyboard catchall"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
	Option "XkbOptions" "caps:super"
EndSection
<snip> 

I found the option you need.  It is in /usr/share/X11/xkb/rules/base.lst, and it is "caps:swapescape".  In my mind, this is the more "correct" way of doing it, as it is done during the initalization of X rather than as an after thought.

I hope this helps!

Last edited by WonderWoofy (2013-04-25 22:55:19)

Offline

#3 2013-04-26 14:31:41

OliK
Member
Registered: 2011-12-15
Posts: 4

Re: [Solved] Strange Problem swapping Esc and Caps lock in X

Or if you want to use ~/.xinitrc:

...
setxkbmap -model evdev -layout us -option caps:swapescape
...

I am using this since a long time and never had problems.

Offline

#4 2013-04-26 15:25:21

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [Solved] Strange Problem swapping Esc and Caps lock in X

I don't use an xinitrc, as my system is entirely systemd --user.  But you are right, this is another option as well.  I guess it also might be handy in that it gives an example if the user ever wants to make other "options" changes to xkb.

Offline

#5 2014-04-26 08:19:39

ccc1
Member
Registered: 2009-04-16
Posts: 111

Re: [Solved] Strange Problem swapping Esc and Caps lock in X

Oh, just saw your answer now!
Thanks, wonderwoofy! your solution works fine smile

ccc1

Offline

#6 2014-04-26 14:35:32

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [Solved] Strange Problem swapping Esc and Caps lock in X

ccc1 wrote:

Oh, just saw your answer now!
Thanks, wonderwoofy! your solution works fine smile

ccc1

Wow, I looked at the date of my previous post and thought, "...but I haven't posted anything today yet!"  But this thread is from exactly a year ago.  ccc1, I commend you for coming back and marking your thread as [Solved]!

Offline

Board footer

Powered by FluxBB