Debian – Reassign Ctrl and Alt keys – xmodmap ‘BadValue’ error

debiankeyboardx11xmodmapxorg

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

any suggestions about how I can resolve this?

Best Answer

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.

Related Question