Ubuntu

xmodmap failure BadValue error, 118 (X_SetModifierMapping)

Reported by Richard Harding on 2010-02-20
82
This bug affects 15 people
Affects Status Importance Assigned to Milestone
X.Org X server
Fix Released
Medium
xorg-server (Ubuntu)
Low
Unassigned

Bug Description

I'm trying to transfer my .xmodmap over to Lucid from karmic.

Error using 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: 16
  Current serial number in output stream: 16

.xmodmap file:

clear control
clear mod4

keycode 66 = Control_L
keycode 37 = Super_L
keycode 133 = Caps_Lock

add control = Control_L Control_R
add mod4 = Super_L

If I remove the line for "add control" then the error does not appear, but then I fail to get my control key mapped to the caps lock.

The end goal is to get
Caps Lock Key == Control
Left Control Key == Mod4

This looks close to the error in this debian bug here:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=564327

Except that I cannot get the xmodmap to take place with/without a call to setxkbmap

ProblemType: Bug
Architecture: amd64
Date: Fri Feb 19 23:22:38 2010
DistroRelease: Ubuntu 10.04
DkmsStatus: Error: [Errno 2] No such file or directory
InstallationMedia: Ubuntu 10.04 "Lucid Lynx" - Alpha amd64 (20100217)
MachineType: LENOVO 7658CTO
Package: xserver-xorg-core 2:1.7.5-1ubuntu1
PccardctlIdent:
 Socket 0:
   no product info available
PccardctlStatus:
 Socket 0:
   no card
ProcCmdLine: BOOT_IMAGE=/boot/vmlinuz-2.6.32-13-generic root=UUID=8c9f29b6-28a1-412d-8030-5fe879a694cd ro single
ProcEnviron:
 PATH=(custom, user)
 LANG=en_US.UTF-8
 SHELL=/bin/zsh
ProcVersionSignature: Ubuntu 2.6.32-13.18-generic
RelatedPackageVersions:
 xserver-xorg 1:7.5+1ubuntu6
 libgl1-mesa-glx 7.7-3ubuntu1
 libdrm2 2.4.18-1ubuntu2
 xserver-xorg-video-intel 2:2.9.1-1ubuntu5
SourcePackage: xorg-server
Uname: Linux 2.6.32-13-generic x86_64
dmi.bios.date: 12/06/2007
dmi.bios.vendor: LENOVO
dmi.bios.version: 7LETA7WW (2.07 )
dmi.board.name: 7658CTO
dmi.board.vendor: LENOVO
dmi.board.version: Not Available
dmi.chassis.asset.tag: No Asset Information
dmi.chassis.type: 10
dmi.chassis.vendor: LENOVO
dmi.chassis.version: Not Available
dmi.modalias: dmi:bvnLENOVO:bvr7LETA7WW(2.07):bd12/06/2007:svnLENOVO:pn7658CTO:pvrThinkPadT61:rvnLENOVO:rn7658CTO:rvrNotAvailable:cvnLENOVO:ct10:cvrNotAvailable:
dmi.product.name: 7658CTO
dmi.product.version: ThinkPad T61
dmi.sys.vendor: LENOVO
glxinfo: Error: [Errno 2] No such file or directory
system:
 distro: Ubuntu
 architecture: x86_64kernel: 2.6.32-13-generic

Richard Harding (rharding) wrote :

I'm trying to transfer my .xmodmap over to Lucid from karmic.

Error using 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: 16
  Current serial number in output stream: 16

.xmodmap file:

clear control
clear mod4

keycode 66 = Control_L
keycode 37 = Super_L
keycode 133 = Caps_Lock

add control = Control_L Control_R
add mod4 = Super_L

If I remove the line for "add control" then the error does not appear, but then I fail to get my control key mapped to the caps lock.

The end goal is to get
Caps Lock Key == Control
Left Control Key == Mod4

This looks close to the error in this debian bug here:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=564327

Except that I cannot get the xmodmap to take place with/without a call to setxkbmap

ProblemType: Bug
Architecture: amd64
Date: Fri Feb 19 23:22:38 2010
DistroRelease: Ubuntu 10.04
DkmsStatus: Error: [Errno 2] No such file or directory
InstallationMedia: Ubuntu 10.04 "Lucid Lynx" - Alpha amd64 (20100217)
MachineType: LENOVO 7658CTO
Package: xserver-xorg-core 2:1.7.5-1ubuntu1
PccardctlIdent:
 Socket 0:
   no product info available
PccardctlStatus:
 Socket 0:
   no card
ProcCmdLine: BOOT_IMAGE=/boot/vmlinuz-2.6.32-13-generic root=UUID=8c9f29b6-28a1-412d-8030-5fe879a694cd ro single
ProcEnviron:
 PATH=(custom, user)
 LANG=en_US.UTF-8
 SHELL=/bin/zsh
ProcVersionSignature: Ubuntu 2.6.32-13.18-generic
RelatedPackageVersions:
 xserver-xorg 1:7.5+1ubuntu6
 libgl1-mesa-glx 7.7-3ubuntu1
 libdrm2 2.4.18-1ubuntu2
 xserver-xorg-video-intel 2:2.9.1-1ubuntu5
SourcePackage: xorg-server
Uname: Linux 2.6.32-13-generic x86_64
dmi.bios.date: 12/06/2007
dmi.bios.vendor: LENOVO
dmi.bios.version: 7LETA7WW (2.07 )
dmi.board.name: 7658CTO
dmi.board.vendor: LENOVO
dmi.board.version: Not Available
dmi.chassis.asset.tag: No Asset Information
dmi.chassis.type: 10
dmi.chassis.vendor: LENOVO
dmi.chassis.version: Not Available
dmi.modalias: dmi:bvnLENOVO:bvr7LETA7WW(2.07):bd12/06/2007:svnLENOVO:pn7658CTO:pvrThinkPadT61:rvnLENOVO:rn7658CTO:rvrNotAvailable:cvnLENOVO:ct10:cvrNotAvailable:
dmi.product.name: 7658CTO
dmi.product.version: ThinkPad T61
dmi.sys.vendor: LENOVO
glxinfo: Error: [Errno 2] No such file or directory
system:
 distro: Ubuntu
 architecture: x86_64kernel: 2.6.32-13-generic

Richard Harding (rharding) wrote :
Bryce Harrington (bryce) on 2010-02-25
Changed in xorg-server (Ubuntu):
status: New → Confirmed
Bryce Harrington (bryce) on 2010-03-10
Changed in xorg-server (Ubuntu):
status: Confirmed → Triaged
importance: Undecided → Low
affects: xorg-server (Ubuntu) → x11-xserver-utils (Ubuntu)
Nathan Howell (neh) wrote :

Is there any chance of this bug getting fixed for Lucid? I just upgraded a few days ago, and am feeling the loss of my usual control keys acutely. If it's not getting fixed, is there a workaround?

Bryce Harrington (bryce) wrote :

xmodmap is not something very high on my priority list given how little time remains for lucid. If you can obtain a patch from upstream (bugs.freedesktop.org) we can consider inclusion of it for lucid. Attach the patch to this bug report and that'll cause it to bubble up to the top of the priority list.

Kieran Hogg (xerosis) wrote :

I found the following patch: https://bugs.freedesktop.org/show_bug.cgi?id=20145

I tried to test it but I couldn't find where the source for xkb is located, I'd be happy to test if someone could point me in the right direction.

Bryce Harrington (bryce) wrote :

Kieran, sure that is a patch to xorg-server.

So apt-get source xorg-server, apply the patch (actually it looks like it won't apply cleanly so you'll need to do it manually), build and test.

However in looking at that patch, it's not obvious how that fixes the problem and makes me wonder if it might end up causing secondary problems in other cases. So even if this patch works, I'd *really* want to see it discussed and taken upstream (or a simpler more obviously-correct patch be made) before we include it in ubuntu.

affects: x11-xserver-utils (Ubuntu) → xorg-server (Ubuntu)
Paolo (plrunner) wrote :

Agree with Nathan. This bug might make many people take Ubuntu of their macbook (et similar) once upgraded to Lucid. Basically many characters and key combination are unfeasible with this bug around.

Paolo

Bryce Harrington (bryce) wrote :

Paolo, so did you test the patch?

NiñoScript (cristian-arenas) wrote :

This greatly affects my workflow, I like making my macbookpro's command keys, Control_L and Control_R, respectively, and the control key a Super.
I and my co-workers are so used to this, that our little fingers ache a little when we use them for complex and/or repetitive keystroke combinations.
We thought about changing the MacOSX side modifier keys to remove inconsistencies but none of us liked it.

When I learnt how to use xmodmap, it was "the" feature that let us change our work environment to linux.

I would be very grateful if you told me how to apply the patch :)

Nathan Howell (neh) wrote :

I just tried the patch and it doesn't work for me.

Is there anything else I can test or look at to help get this bug fixed? It's just destroying every control- shortcut I use because my control keys aren't where I expect. Oddly, my other keys remapped with xmodmap work; it's just control keys that don't.

Is there another way to map keys? I tried looking into xkb, but can't find a way to just remap a key with it.

Reinhard (seifert-reinhard) wrote :

This bug is really serious and if not fixed will make me leave Lucid at once.

My whole workflow is resting on " Hyper_L on CapsLock " or precisely:

xmodmap -e 'remove lock = Caps_Lock'
xmodmap -e 'keycode 66 = Hyper_L'
xmodmap -e 'add mod3 = Hyper_L'

I am using emacs 99% of the time and without the Hyper-key on Caps_Lock -> no emacs...

You can imagine what that means..... any help very appreciated!

I wondered if it is possible to manipulate the keymap manually on a "deeper" level, so that I do not have to rerun the script each time I reboot, logout or run setxkbmap?

NiñoScript (cristian-arenas) wrote :

I figured out how to change that stuff myself without needing xmodmap, yay for me :)

In this file: /usr/share/X11/xkb/keycodes/evdev
I found these lines:

<LALT> = 64;
<LCTL> = 37;
<SPCE> = 65;
<RCTL> = 105;
<RALT> = 108;
// Microsoft keyboard extra keys
<LWIN> = 133;
<RWIN> = 134;

which I changed for these ones:

<LALT> = 108;
<LCTL> = 133;
<SPCE> = 65;
<RCTL> = 134;
<RALT> = 64;
// Microsoft keyboard extra keys
<LWIN> = 37;
<RWIN> = 105;

then logout/login, and tadá!
controls in "command" key
super in "control" key
alt for 3rd level (altgr) in the left
alt for options and stuff in the right

just how I like it!

Hope it helps someone :)

Wayne (wayne-zhang) wrote :

Great, NiñoScript's solution works for me!

NiñoScript (cristian-arenas) wrote :

Yay! I helped someone :D
Hooray for me! :)

I found the same problem when I upgraded from 9.04 to 10.04.

Specifically, I was remapping another key to Control_L, with

xmodmap -e 'keycode 133 = Control_L'
xmodmap -e 'add Control = Control_L'

But the 'add Control = Control_L' line fails, with the same error mentioned above.

NiñoScript's workaround didn't work for me, but it can't be a permanent solution anyway (as it won't survive x upgrades).

Reinhard (seifert-reinhard) wrote :

Yes, thanks NiñoScript's workaround worked. Not as I anticipated, but in the end CapsLock became Hyper_L.

I changed
<CAPS> = 66;
to
<HYPR> = 66;

and commented away the original (<HYPR> = 208; or something like that).

Then I still needed to run
xmodmap -e 'keycode 66 = Hyper_L'

... did not fully understand the keycode concept in xorg, but for now it works, so I leave it for that.

Thx,
Reinhard

Vincent Ladeuil (vila) wrote :

I was bitten by the same bug while using a specific ~/.xmodmaprc to switch the option and command keys
on a macintosh keyboard.

Applying the following patch works around the problem:

 ! Remove Mod1 and Mod4 mappings (as shown by xmodmap on fresh config)
-remove Mod1 = Alt_L
-remove Mod1 = Meta_L
+clear Mod1
+clear Mod4

-remove Mod4 = Super_L
-remove Mod4 = Hyper_L
+! clear some mess coming out from ?
+keycode 204 = NoSymbol NoSymbol NoSymbol NoSymbol
+keycode 205 = NoSymbol NoSymbol NoSymbol NoSymbol
+keycode 206 = NoSymbol NoSymbol NoSymbol NoSymbol
+keycode 207 = NoSymbol NoSymbol NoSymbol NoSymbol

 ! Add keycodes as shown by xev
-keycode 64 = Super_L
-keycode 108 = Super_R
-keycode 133 = Alt_L
-keycode 134 = Alt_R
+keycode 64 = Super_L Super_L Super_L Super_L
+keycode 108 = Super_R Super_R Super_R Super_R
+keycode 133 = Alt_L Alt_L Alt_L Alt_L
+keycode 134 = Alt_R Alt_R Alt_R Alt_R

I have tracked down precisely which of the modifications (clearing the 205-207 keycodes, using 'clear'
 instead of 'remove' to clean the modifiers or settings the four values for the keycodes) addressed the problem.

Hopefully the xorg-server hackers may under the issue better than me.

ViktigLemma (jorgsk) wrote :

For those who specifically only wish to make Caps Lock into Control, I found help at this site:
http://mina86.com/2009/10/11/more-control-no-caps-lock/

What it says:

1) Open /etc/default/console-setup

2) Add ctrl:nocaps to XKBOPTIONS,
for example from
XKBOPTIONS=""
to
XKBOPTIONS="ctrl:nocaps"
(in my case from
XKBOPTIONS="grp:alts_toggle"
to
XKBOPTIONS="grp:alts_toggle,ctrl:nocaps")

3) Run dpkg-reconfigure console-setup as root and make all the correct choices for your setup

It worked for me!

I bet more options can be put there that could solve other problems too.

This bug is hugely annoying. Please please fix it.

Gerard (gbrunick) wrote :

I got this error as well, but I kept messing with my script that changes the key modifiers and it seems to work for me now. The script is attached in the hopes that it may help someone else until this is resolved/better understood.

Zm (z-m) wrote :

NiñoScript's solution works for me too. I had to do both "<RCTL> = 134;" and "<RWIN> = 105;" to remap my right Command button as Ctrl; if I don't remap RWIN, it doesn't work.

Takashi Hatai (takashi-hatai) wrote :

I also got this error. But NinoScript's workaround works well. Thank you, NinoScript!
Here is another tip. The following command can be used to reload the settings, instead of login/logout.

  $ setxkbmap -model evdev

In my environment, I need to reload the settings everytime when I plug-off/plug-in my USB keyboard. And it's easier than login/logout.

Changed in xorg-server:
importance: Unknown → Medium
status: Unknown → Confirmed
marco caminati (spam-caminati) wrote :

Here I have the same bug:

X.Org X Server 1.7.7
Release Date: 2010-05-04
X Protocol Version 11, Revision 0
Build Operating System: Linux 2.6.33.3-tinycore i686
Current Operating System: Linux box 2.6.33.3-tinycore #2012 SMP Wed May 12 17:05:42 EEST 2010 i686
Kernel command line: multivt showapps superuser text norestore
Build Date: 28 May 2010 06:50:29PM

My .xmodmap file:

xmodmap -e "remove lock = Caps_Lock"
xmodmap -e "add Mod3 = Caps_Lock"

However, I found that the problem doesn't necessarily throw the error message quoted in original report. After a reboot the one-liner:

DISPLAY=:0.0 xmodmap -e "clear lock"

will silently fail from deallocating CapsLock.
More precisely, if I issue it from a non-X console, it has no effect, while from a xterm it works. I compared the environment variables from within the two consoles. No significant differences (only DISPLAY and TERM variables). I also took care of equaling the environment variables of the console to that of the xterm, no way. Weird.

intuited (intuited) wrote :

I've started using a different machine recently, and was initially not experiencing this bug. I'm running xfce under 10.10. IIRC I originally installed xubuntu on this box but have also installed the ubuntustudio package as well as kubuntu-desktop and possibly ubuntu-desktop. Anyway this erroneous behaviour with xmodmap, specifically

    $ 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

started when I added the Keyboard Layouts applet to a panel. I added the Canadian Multilingual keyboard to the initial default of US. The switcher combo was set to Alt+CapsLock. At this point I had already run this xmodmap script

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

which switches CapsLock and Escape. This had been working normally up until this point, but IIRC the keyboard setup reverted to the default after I accepted the Keyboard Layouts preferences. When I tried to re-run my script, I got the above-quoted error message.

I've filed an `upstream bug report`_ which, it would appear, is not a duplicate.

.. _upstream bug report: https://bugs.freedesktop.org/show_bug.cgi?id=31436

marco caminati (spam-caminati) wrote :

Same environment specified in my 10 hours old message.
I do: Ctrl-Alt-F1 to go to a tty. then

tc@box:~$ echo "remove lock = Caecho "remove lock = Caps_Lock"| DISPLAY=:0.0 xmodmap -v -
! stdin:
! 1: remove lock = Caps_Lock
! Keysym Caps_Lock (0xffe5) corresponds to keycode(s) 0x42
        remove lock = 0x42
!
! executing work queue
!
        remove lock = 0x42
tc@box:~$ DISPLAY=:0.0 xmodmap -v
!
! executing work queue
!
xmodmap: up to 4 keys per modifier, (keycodes in parentheses):

shift Shift_L (0x32), Shift_R (0x3e)
lock
control Control_L (0x25), Control_R (0x6d)
mod1 Alt_L (0x40), Alt_R (0x71), Meta_L (0x9c)
mod2 Num_Lock (0x4d)
mod3
mod4 Super_L (0x73), Super_R (0x74), Super_L (0x7f), Hyper_L (0x80)
mod5 Mode_switch (0x5d), ISO_Level3_Shift (0x7c)

Then I do Alt-F7 and Ctrl-Alt-F1 to just pay a mere visual visit to Xorg server. Back in tty:

tc@box:~$ DISPLAY=:0.0 xmodmap -v
!
! executing work queue
!
xmodmap: up to 4 keys per modifier, (keycodes in parentheses):

shift Shift_L (0x32), Shift_R (0x3e)
lock Caps_Lock (0x42)
control Control_L (0x25), Control_R (0x6d)
mod1 Alt_L (0x40), Alt_R (0x71), Meta_L (0x9c)
mod2 Num_Lock (0x4d)
mod3
mod4 Super_L (0x73), Super_R (0x74), Super_L (0x7f), Hyper_L (0x80)
mod5 Mode_switch (0x5d), ISO_Level3_Shift (0x7c)

So the effect of xmodmap lasts until Xorg takes the display. I have an impression that the bug is related to his behaviour. Hope this is not just noisy blur around the real bug.

intuited (intuited) wrote :

I've discovered that the addition of the Canadian Multilingual keyboard (ca-multix) specifically triggers the bug behaviour. I.E. If I add it in the properties dialog for xfce's Keyboard Settings applet, I will subsequently be
unable to do ``xmodmap -e 'clear Lock'`. Removing the Canadian Multilingual keyboard as one of the keyboard options will cause that xmodmap command to work again.

The problem does not occur (i.e. xmodmap works correctly) if I instead add the keyboard Canada -> "Multilingual (first part)" (ca-multi). So this may prove to be a good workaround for myself and perhaps others, and may provide a useful clue to people who can track down this bug.

Also: this issue is `rumoured`_ to be related or identical to `<https://bugs.freedesktop.org/show_bug.cgi?id=20145>`_

.. _rumoured:
http://unix.stackexchange.com/questions/4541/diagnosing-xmodmap-errors#comment-5291

marco caminati (spam-caminati) wrote :

Being not literate enought to parse Xorg source code, I tested the following dirty and unreliable hack. The stupid idea is to use xmodmap only when the Xorg window is displayed, based on my last comment. This working (for me) should give some support to that comment:

#!/bin/sh

BLAHBLAH
.
.
.
startx
waitforX
export DISPLAY=:0.0
(
export CURTTY=A
until [ $CURTTY -eq 7 ]
do
chvt 7
CURTTY=`fgconsole`
done
xmodmap -display "${DISPLAY}" -v ~/.Xmodmap
) &

...the rest of your script...

This is a horrible workaround, and moreover I occasionally observed Xorg being just crashed by xmodmap (I can't reproduce that aptly, though). Allowed me to do what I wanted (reassign the mod key for wmii window manager, by the way), anyway.

Changed in xorg-server:
importance: Medium → Unknown
Changed in xorg-server:
importance: Unknown → Medium
Changed in xorg-server:
status: Confirmed → Fix Released
Bryce Harrington (bryce) wrote :

According to the upstream bug report, this was fixed with commit 836864b65794dc0954a01245e418e714cead8125 which I've confirmed is included in the natty, maverick, and lucid xservers.

Changed in xorg-server (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.