When I try to move keys, so that I have CapsLock on escape, Control on CapsLock and Escape on left control, I get the following error:

% xmodmap ~/.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:  15
  Current serial number in output stream:  15

That is the code that fails:

remove Lock = Caps_Lock

keycode 9 = Caps_Lock
add Lock = Caps_Lock
remove Control = Control_L

! CapsLock
keycode 66 = Control_L
add control = Control_L

! Control_R
keycode 37 = Escape

! 2*Meta_L
keycode 148 = Meta_L
add mod1 = Meta_L

If I comment out all lines that start with either add or remove it runs without any errors, but does not do what I want.

Program versions (Gentoo x86 (stable)):

  • xorg-server-1.7.6
  • xmodmap-1.0.4
  • xf86-input-evdev-2.3.2


# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 1.0  (buildmeister@builder63)  Fri Aug 14 17:54:58 PDT 2009

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0"
    InputDevice    "Evdev Keyboard" "CoreKeyboard"
    InputDevice    "Evdev Mouse" "CorePointer"
Section "Module"
    Disable "dri"
    Disable "dri2"

Section "InputDevice"
    Identifier  "Evdev Keyboard"
    Driver      "evdev"
    Option      "Device"     "/dev/input/event2"
    Option      "CoreKeyboard"
    Option      "AutoRepeat" "500 25"
    Option      "XkbRules"   "xorg"
    Option      "XkbModel"   "yahoo"
    Option      "XkbLayout"  "dvp2"
    Option      "XkbOptions"  "grp_led:scroll,grp:rctrl_toggle,compose:rwin,grp:lwin_switch"

Section "InputDevice"
   Identifier    "Evdev Mouse"
   Driver        "evdev"
   Option        "CorePointer"
   Option        "Device"                    "/dev/input/event3"
   Option        "Name"                      "Genius Ergo Mouse"
   Option        "HWHEELRelativeAxisButtons" "7 6"
   Option        "WHEELRelativeAxizButtons"  "4 5"
   Option        "SendCoreEvents"            "true"
   Option        "Buttons"                   "11"

Section "Files"
    FontPath "/usr/share/fonts/misc"
    FontPath "/usr/share/fonts/Type1"
    FontPath "/usr/share/fonts/100dpi"
    FontPath "/usr/share/fonts/75dpi"

    FontPath "/usr/share/fonts/terminus"
    # FontPath "/usr/share/fonts/intlfonts"

    FontPath "/usr/share/fonts/ttf-bitstream-vera"
    # FontPath "/usr/share/fonts/ttf"
    FontPath "/usr/share/fonts/corefonts"

    FontPath "/usr/share/fonts/paratype"

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    HorizSync       28.0 - 33.0
    VertRefresh     43.0 - 72.0
    Option         "DPMS"

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24

#Section "Extensions"
    #Option "Composite" "Disable"
Section "ServerFlags"
    Option         "AutoAddDevices" "false"
    Option         "DontVTSwitch" "false"
    Option         "DontZap" "false"
    Option         "DontZoom"     "true"

Everything worked before update.

  • I can forget about caps lock: I do not use it, and use xkboption ctrl:nocaps to map control on caps lock. But how to map mod1 (alt) to XF86Calculator key (it is near the space bar on my keyboard)? – ZyX Apr 27 '10 at 15:16
  • Last issue was solved: to map XF86Calculator to alt modifier I must take existing modifier's character name (it is Alt_L). Still wondering about how to map escape to caps lock, but, as I said, I never use it. – ZyX Apr 27 '10 at 15:23
  • I get the same error, also on gentoo. – Flow May 20 '11 at 5:19

Most of the time when I get this error it's because I try to assign a key-sym to a modifier but that key-sym is already used for a different modifier. Try running "xmodmap -pm" and verify that the key-syms you are trying to assign to modifiers are not already used.

For example, if Meta_L is already assigned to, say, mod4 then you might get this error if you try to assign Meta_L to mod1 without first removing it from mod4.


According to the Xmodmap Manual, there is at least one key step it appears you have left out. Not only must you "remove" the modifier bit assignments you must also "clear" the keys from the modifier groups.

Yes, it IS confusing, I know!

It also seems that these tasks/commands must be run in a certain order:

  1. The removal/clearing of assignments to groups & keys
  2. Assign the keysyms to the desired keycodes
  3. Add the keysyms to the appropriate modifier groups

I see that this thread has been inactive for a while and it is clearly dead (the OP has resolved or given up on this issue). But hopefully this clarification may help someone else dealing with a similar situation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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