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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm getting this error when trying to use xmodmap to get rid of caps lock:

$ xmodmap -e 'clear Lock'
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:  8
  Current serial number in output stream:  8

I'm running xfce. This problem did not occur before I added the Keyboard Layouts applet to a panel; before doing that, I was able to run my xmodmap script to swap Esc and CapsLock:

!Remap Caps_Lock as Escape
remove Lock = Caps_Lock
keysym Caps_Lock = Escape

It may be relevant that I chose alt-capslock as the keyboard switch combo in the Keyboard Layouts preferences.

I've had a similar problem before, on a different machine, running openbox. On that machine, this problem started when I upgraded to Lucid. I reported a bug in xorg. However, it remains unclear whether it's really a problem with xorg, or if I'm just doing something wrong with my configuration.

Have other people experienced this problem? Can someone shed some light on what's going on here? It seems there are quite a few layers involved, and I don't understand any of them particularly well, so any information would be helpful.


I've discovered that the problem is specifically triggered by adding the Canada layout variant "Multilingual" (ca-multix). If I instead add the variant "Multilingual (first part)" (ca-multi), the problem does not occur. I think this will probably end up being a usable workaround, but I don't yet know what the difference between these variants is.

I've filed a freedesktop issue, and am commenting on a related ubuntu issue.

share|improve this question
crossposted to Ask Ubuntu – intuited Dec 5 '10 at 4:00
Your bug looks the same as the one discussed here and reported to Xorg and Ubuntu. – Gilles Dec 5 '10 at 17:54
post the update as an answer? – xenoterracide Dec 6 '10 at 12:54
@xenoterracide: I don't really feel like I've gotten the answer though.. my question was intended to be more about how to figure out what's wrong than about how to fix it. I still have pretty much zero clue how this stuff works, and just happened to stumble on a more specific set of reproduction steps. The most recent comment on the freedesktop issue mentions that there might be some work done towards a bug fix within the next couple of weeks; if there ends up being a patch or something I guess I'll post that as an answer. – intuited Dec 7 '10 at 5:42
@intuided ok. sorry wish I could be of more help, I haven't used xmodmap in years now. – xenoterracide Dec 7 '10 at 9:27

Modern Xorg uses the XKB extension for supporting keyboard layouts. Xmodmap is emulated through a compatibility layer, but it has quirks. You can disable XKB entirely and Xorg will revert to using the old Xmodmap keyboard mappings. I think it's setting the option XkbDisable to true in xorg.conf, but you probably want to do it the XKB method. There are many configurable options located in /usr/share/X11/xkb/rules/xorg.xml and I think you want caps:swapescape which swaps Caps Lock and Escape. Try setxkbmap -option caps:swapescape

share|improve this answer

The problem arises when you try to add an keysym to an modifier which is already added to another modifier key. It is vital to know, that if you add an keysym to an 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 (or .xmodmap,... You can 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
setxkbmap -option caps:escape # use caps as esc


setxkbmap -option caps:swapescape # to swap caps with esc
share|improve this answer

Your Answer


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.