You are not logged in.

#1 2010-03-10 23:40:07

the gray
Member
From: Croatia
Registered: 2009-03-16
Posts: 21

xmodmap and keyboard led wierdness

hello fellow archers!

my window manager is openbox and i use xmodmap to swap caps lock and escape keys with the following configuration file:

~/.keyswap

remove Lock = Caps_Lock
remove Control = Escape
keysym Escape = Caps_Lock
keysym Caps_Lock = Escape
add Lock = Caps_Lock
add Control = Escape

and now comes the wierd part: when i run "xmodmap ~/.keyswap" manually from terminal
or using gmrun it works as expected and escape key toggles the caps lock led on the keyboard. but if i put the same command in my
autostart.sh or in .xinitrc the keys are swapped but caps lock key still toggles the caps lock led on the keyboard.
i've tried everything i found in the various forums and on google but this behaviour still persists. while it's
not a showstopper it is an annoyance. could this be a some kind of a bug or i missed something?

thank you in advance for your input.

best regards

Offline

#2 2010-03-10 23:44:41

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: xmodmap and keyboard led wierdness

No guarantees, but my .Xmodmap begins with

clear Lock

Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2010-03-10 23:51:04

the gray
Member
From: Croatia
Registered: 2009-03-16
Posts: 21

Re: xmodmap and keyboard led wierdness

just tried adding that. no effect

Offline

#4 2010-03-11 01:27:40

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: xmodmap and keyboard led wierdness

This is an unsolved problem for quite some time.
A similar xmodmap does not work here neither whith .xinitrc nor openbox autostart.sh. It appears to be an X issue.


To know or not to know ...
... the questions remain forever.

Offline

#5 2010-03-11 07:02:10

chpln
Member
From: Australia
Registered: 2009-09-17
Posts: 361

Re: xmodmap and keyboard led wierdness

I'm wondering whether this is caused by a race condition.  Does invoking xmodmap with something like this help?

( sleep 5; xmodmap ~/.keyswap ) &

Offline

#6 2010-03-11 08:23:58

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: xmodmap and keyboard led wierdness

It does not work here. I suspect that X either does not see the xmodmap change or simply resets it at startup. It might be a hal issue as well but I did not check this one.

I finally wrote a simple keyboard changer script and bound this to a shortcut key so it is a mere nuisance now. (And I can revert the mapping if I want to.)


To know or not to know ...
... the questions remain forever.

Offline

#7 2010-03-11 11:23:28

the gray
Member
From: Croatia
Registered: 2009-03-16
Posts: 21

Re: xmodmap and keyboard led wierdness

i have already tried delaying xmodmap starting. it had no effect.
now i noticed that the caps lock key, if i try to autostart xmodmap, functions as both escape and caps lock, but xev reports that only escape was pressed.
and it does that only if i try to autostart xmodmap. if i launch it manually everything is perfect.

Offline

#8 2010-03-11 11:38:47

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: xmodmap and keyboard led wierdness

I remember having similar problems. Now I do use in fact three separate definitions:

$ cat EscCL_swapped 
! Swap caps lock and escape
remove lock =  0x42
keycode 0x9 = Caps_Lock
keycode 0x42 = Escape
add lock = Caps_Lock

$ cat EscCL_standard 
! Original caps lock and escape
remove lock =  0x42
keycode 0x9 = Escape
keycode 0x42 = Caps_Lock
add lock = Caps_Lock

$ cat EscCL_toggle 
! Toggle caps lock and escape key arrangements
remove Lock = Caps_Lock
keysym Escape = Caps_Lock
keysym Caps_Lock = Escape
add Lock = Caps_Lock

Maybe it helps. smile


To know or not to know ...
... the questions remain forever.

Offline

#9 2010-03-11 17:00:30

the gray
Member
From: Croatia
Registered: 2009-03-16
Posts: 21

Re: xmodmap and keyboard led wierdness

i've tried your definitions and that wierd behaviour still persists. and i've also tried every method of keyboard configuration (xorg.conf, hal, every available driver) and still a no go. so it shouldn't be a keyboard driver or configuration fault.

now i have another question: do the system or xorg log keymap changes anywhere? if there's a log i might be able to find something of use there.
btw, in Xorg.log the only keyboard relevant lines are:

(**) Option "CoreKeyboard"
(**) Keyboard0: always reports core events
(**) Option "Protocol" "standard"
(**) Keyboard0: Protocol: standard
(**) Option "XkbRules" "base"
(**) Keyboard0: XkbRules: "base"
(**) Option "XkbModel" "pc105"
(**) Keyboard0: XkbModel: "pc105"
(**) Option "XkbLayout" "hr"
(**) Keyboard0: XkbLayout: "hr"
(**) Option "CustomKeycodes" "off"
(**) Keyboard0: CustomKeycodes disabled

Offline

#10 2011-03-06 19:40:56

jichuan89
Member
From: Mountain View, CA
Registered: 2010-03-10
Posts: 9
Website

Re: xmodmap and keyboard led wierdness

Hey guys,

I've been having the same issue and ended up with a script with a while loop that is called from my startup script (autostart.sh under Openbox) that does the job. I put something along the lines of

while xmodmap | grep '^lock.*(0x42)' ; do
    xmodmap ~/.keyswap
    sleep 1
done

in a separate script called ~/Tools/keyswap, ran chmod +x on it, and put

~/Tools/keyswap &

in my autostart.sh. I found that you couldn't embed the loop inside autostart.sh directly and must execute the script in the background or Openbox would never start.

Of course, change the grep in the condition to match what you actually want to do with xmodmap.

Cheers.

Last edited by jichuan89 (2011-03-06 20:05:00)

Offline

#11 2011-03-27 23:31:43

Markus00000
Member
Registered: 2011-03-27
Posts: 323

Re: xmodmap and keyboard led wierdness

jichuan89,

I have set it up exactly like you proposed but no remapping takes place on Openbox startup. If I manually run my equivalent to "~/Tools/keyswap", it's being remapped instantly. In the console I see that "keyswap" is indeed being executed on startup of Openbox.

Edit: "Fixed" it with this ugly .xinitrc entry: "(sleep 1 && xmodmap .Xmodmap && sleep 1 && xmodmap .Xmodmap && sleep 1 && xmodmap .Xmodmap) &" Running the command less often does not reliably work for me.

Last edited by Markus00000 (2011-04-07 18:26:11)

Offline

Board footer

Powered by FluxBB