You are not logged in.

#1 2009-04-02 18:05:31

rickynils
Member
Registered: 2006-10-18
Posts: 9

xmodmap troubles

Hi,

I have a strange problem with xmodmap. In my startup scripts, I run "xmodmap /home/.../.xmodmaprc" before starting my window manager, xmonad. My .xmodmaprc file looks like this (mapping CapsLock to Control_R):

clear lock 
keycode 66 = Control_R 
add control = Control_R

However, this messes up my right Alt-button, making it impossible to write for example @-tokens. If run xmodmap -pm I get the following output:

xmodmap:  up to 3 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock      
control     Control_L (0x25),  Control_R (0x69),  Control_R (0x42)
mod1        Alt_L (0x40),  ISO_Level3_Shift (0x6c),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod3      
mod4        Super_L (0xce),  Hyper_L (0xcf)
mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)

The strange thing is that ISO_Level3_Shift (which my right Alt key is mapped to) appears in mod1. Because if I don't run xmodmap on startup, xmodmap -pm returns the following:

xmodmap:  up to 2 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod3      
mod4        Super_L (0xce),  Hyper_L (0xcf)
mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)

Finally, if I run "xmodmap ~/.xmodmaprc from a terminal after I have started my window manager (and don't run it from the startup script), then I get the correct mappings, and my keys work as expected:

xmodmap:  up to 3 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock      
control     Control_L (0x25),  Control_R (0x69),  Control_R (0x42)
mod1        Alt_L (0x40),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod3      
mod4        Super_L (0xce),  Hyper_L (0xcf)
mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)

So the question is why do xmodmap behave differently depending on when it is executed? I have tried letting xmonad run xmodmap when it starts, but it also gives the incorrect mappings. Only if I run xmodmap from a terminal, it behaves correctly.

Has anyone seen this behaviour before? Or do someone have a suggestion about what I could try?

Offline

#2 2009-04-02 18:39:14

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,799
Website

Re: xmodmap troubles

that's very odd behavior.  i can't tell you why but i can give you a workaround:

# .xinitrc
(sleep 3 && xmodmap $HOME/.xmodmaprc) &

this should mimic you starting X, waiting 3 seconds (at which time your window manager should be loaded?), then running the command yourself which you say, works as you need.

let me know how it turns out.

Last edited by brisbin33 (2009-04-02 18:42:19)

Offline

#3 2009-04-02 18:59:28

rickynils
Member
Registered: 2006-10-18
Posts: 9

Re: xmodmap troubles

It did help, although I had to increase the sleep time to 8 seconds. This is strange. Could it maybe have something with evdev/hal autodetection of the keyboard to do? Maybe xmodmap is executed before the keyboard is intialized?

Offline

#4 2009-04-02 19:45:13

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,799
Website

Re: xmodmap troubles

it's got to be some conflict between X setting the keymap and xmodmap doing it's thing.  do you have any kbd or keymap options in your xorg.conf?  i used to start xmodmap via .xinit (w/o the sleep part) and it worked fine.  i've since stopped doing that so i don't know.  i've heard xmodmap is buggy in general anyway, maybe try xbindkeys?

Offline

#5 2009-04-03 06:13:20

rickynils
Member
Registered: 2006-10-18
Posts: 9

Re: xmodmap troubles

I looked briefly at xbindkeys now, but to me it did seem as if it was only for mapping keys to commands? Or is it possible to change the X modifiers and key mappings with it?

Offline

#6 2009-04-03 13:43:05

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,799
Website

Re: xmodmap troubles

rickynils wrote:

I looked briefly at xbindkeys now, but to me it did seem as if it was only for mapping keys to commands? Or is it possible to change the X modifiers and key mappings with it?

you may be right, i've never used it.  maybe someone else can jump in with a possible fix for you.

Offline

Board footer

Powered by FluxBB