Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am attempting to remap my keyboard in order to make emacs usable - my ergonomic keyboard puts its single Control key in an isolated 4-key island way off to the left.

The OS is debian squeeze.

Here are the lines I am attempting to feed to xmodmap, I place them into a file ~/.Xmodmap

clear Control
clear Mod1
! The Alt keys are labled 'Option' on my keyboard, 
! using xev shows them to send Alt_L and Alt_R keysym's respectively 
keysym Alt_L = Control_L
keysym Alt_R = Control_R
! The Super_L and Super_R keys are the Windows keys
keysym Super_L = Alt_L
keysym Super_R = Alt_R
add Control = Control_L Control_R
add Mod1 = Alt_L Alt_R

My goal is to make my Option (a.k.a. Alt) keys behave like Control keys, and to get my Windows (a.k.a. Super) keys to behave like Alt.

Here are the keycodes and keysms output by xev for the keys in question. Note, my keyboard (a Goldtouch ergonomic keyboard) has only one control key.


keycode 37 (keysym 0xffe3, Control_L)
keycode 64 (keysym 0xffe9, Alt_L)
keycode 133 (keysym 0xffeb, Super_L)
keycode 134 (keysym 0xffec, Super_R)
keycode 108 (keysym 0xffea, Alt_R)

Here is what xev displays while running xmodmap .Xmodmap



MappingNotify event, serial 34, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 204, count 1

MappingNotify event, serial 34, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 64, count 1

MappingNotify event, serial 34, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 108, count 1

MappingNotify event, serial 34, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 206, count 1

MappingNotify event, serial 34, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 133, count 1

MappingNotify event, serial 34, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 134, count 1

And here is the error returned by xmodmap:

X Error of failed request:  BadValue (integer parameter out of range for operation)
Major opcode of failed request:  118 (X_SetModifierMapping)
Value in failed request:  0x17
Serial number of failed request:  17
Current serial number in output stream:  17

Whats the deal?

share|improve this question
    
On what operating system and version? What broad type of keyboard (PC/Mac/Sun/...)? Try runnning xev in a terminal, then xmodmap in another terminal. You should see some MappingNotify stanzas from xev, add them to your question. Also, in the xev window, press the various keys involved and tell us what keycode and keysym they correspond to (the “keycode 37 (keysym 0xffe3, Control_L)” part of the xev output). –  Gilles Dec 2 '10 at 20:08

4 Answers 4

up vote 3 down vote accepted

This has already been reported as Debian bug #564327, Debian bug #565279, Ubuntu bug #524774, and FreeDesktop bug 20145. There is a source patch attached to the FreeDesktop bug discussion. There are several workaround proposals in the Ubuntu bug discussion, in particular a .Xmodmap workaround.

share|improve this answer

Looking at the workaround linked by Giles, this is what worked for me:

clear Mod1
clear Mod4

keycode 204 = NoSymbol NoSymbol NoSymbol NoSymbol
keycode 206 = NoSymbol NoSymbol NoSymbol NoSymbol

keycode 64 = Control_L Control_L Control_L Control_L
keycode 133 = Alt_L Alt_L Alt_L Alt_L
keycode 134 = Alt_R Alt_R Alt_R Alt_R
keycode 108 = Control_R Control_R Control_R Control_R

add Control = Control_L Control_R
add Mod1 = Alt_L Alt_R

My Option keys now function like Control keys and my Windows Keys like Alt keys.

share|improve this answer

The problem arises when you try to add a keysym to a modifier which is already added to another modifier key. It is vital to know, that if you add a keysym to a modifier all other keysyms that companion the keysym in case are added also as to that modifier.

For example:

clear mod5
add mod5    = ISO_Level3_Shift Mode_switch

can result in

mod5        backslash (0x33),  Caps_Lock (0x42),  ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)

because you have something like

keycode  66 = Caps_Lock NoSymbol ISO_Level3_Shift

in your ~/.Xmodmap (View the current keycode to keysym mapping via xmodmap -pke)

which will produce the BadValue error in question when you also try to do something like

add lock    = Caps_Lock

because Caps_Lock is already added to the mod5 modifier.

share|improve this answer

This is another solution to your problem although it doesn't really answer your question. Edit xorg.conf, inserting the following into Section "InputDevice":

 Option "XkbOptions" "ctrl:swapcaps"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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