Reassign Ctrl and Alt keys - xmodmap 'BadValue' error
Solution 1
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.
Solution 2
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.
Solution 3
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.
Solution 4
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"
Related videos on Youtube
Aliud Alius
Updated on September 17, 2022Comments
-
Aliud Alius over 1 year
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?
-
Gilles 'SO- stop being evil' over 13 yearsOn what operating system and version? What broad type of keyboard (PC/Mac/Sun/...)? Try runnning
xev
in a terminal, thenxmodmap
in another terminal. You should see someMappingNotify
stanzas fromxev
, add them to your question. Also, in thexev
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).
-