You are not logged in.

#1 2012-05-29 16:09:03

lahwaacz
Wiki Admin
From: Czech Republic
Registered: 2012-05-29
Posts: 776

Xmodmap - switch CapsLock and Tab

My Tab key is broken (it works, but I must press it really hard), so I need to switch CapsLock and Tab keys (CapsLock isn't used so frequently so it can be broken key). I found two ways of doing this with xmodmap. First way:

remove Lock = Caps_Lock
keysym Tab = Caps_Lock
keysym Caps_Lock = Tab
add Lock = Caps_Lock

Second:

clear Lock
keycode  66 = Tab ISO_Left_Tab Tab ISO_Left_Tab
keycode  23 = Caps_Lock NoSymbol Caps_Lock

Both work fine when I run maually

xmodmap ~/.Xmodmap

, but when I put

if [ -f ~/.Xmodmap ]; then
    xmodmap ~/.Xmodmap
fi

in my .xinitrc file, Tab key becomes CapsLock, but CapsLock key works as both Tab and CapsLock. I also tried

if [ -f ~/.Xmodmap ]; then
    (sleep 5 && xmodmap ~/.Xmodmap) &
fi

but the result is the same.

Last edited by lahwaacz (2012-05-29 16:09:38)

Offline

#2 2012-05-29 16:13:46

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: Xmodmap - switch CapsLock and Tab

Why not simply use setxkbmap in your .xinitrc and set the correct keycodes for your Tab key to the Caps Lock ?

setxkbmap -option caps:tab

Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#3 2012-05-29 16:39:47

lahwaacz
Wiki Admin
From: Czech Republic
Registered: 2012-05-29
Posts: 776

Re: Xmodmap - switch CapsLock and Tab

Inxsible wrote:

Why not simply use setxkbmap in your .xinitrc and set the correct keycodes for your Tab key to the Caps Lock ?

setxkbmap -option caps:tab

Well, this doesn't work for me...

Offline

#4 2012-05-29 16:52:35

lahwaacz
Wiki Admin
From: Czech Republic
Registered: 2012-05-29
Posts: 776

Re: Xmodmap - switch CapsLock and Tab

I think it's irrelevant, but I've switched the keys for console.
/usr/local/share/kbd/keymaps/personal.map:

keycode 58 = Tab
keycode 15 = Caps_Lock

/etc/rc.local:

loadkeys /usr/local/share/kbd/keymaps/personal.map

Or is there any way to tell X to keep console key maps?

Offline

#5 2012-05-29 16:53:36

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: Xmodmap - switch CapsLock and Tab

did you check the correct keycode names for caps and tab ? and if so, are you getting any errors in your logs? If so post them

Just saying "doesn't work for me" doesn't help anyone !


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#6 2012-05-29 17:57:23

lahwaacz
Wiki Admin
From: Czech Republic
Registered: 2012-05-29
Posts: 776

Re: Xmodmap - switch CapsLock and Tab

Inxsible wrote:

did you check the correct keycode names for caps and tab ? and if so, are you getting any errors in your logs? If so post them
Just saying "doesn't work for me" doesn't help anyone !

Yes, I checked the keycodes. Console settings are fine. Xmodmap works fine when I run it manually, but not from xinitrc.

/var/log/Xorg.0.log doesn't say much about keyboard, only settings from /etc/X11/xorg.conf.d/20-keyboard_layout.conf and initializing hardware.

Output of setxkbmap -v 10 -option caps:tab:

Setting verbose level to 10
locale is C
Trying to load rules file ./rules/evdev...
Trying to load rules file /usr/share/X11/xkb/rules/evdev...
Success.
Applied rules from evdev:
rules:      evdev
model:      pc105
layout:     cz,us
options:    caps:tab,grp:alt_shift_toggle
Trying to build keymap using the following components:
keycodes:   evdev+aliases(qwertz)
types:      complete
compat:     complete
symbols:    pc+cz+us:2+inet(evdev)+group(alt_shift_toggle)
geometry:   pc(pc105)

Offline

Board footer

Powered by FluxBB