Xmodmap 无法重新映射修饰键

Xmodmap 无法重新映射修饰键

当我尝试移动按键,以便在退出键上有 CapsLock,在 CapsLock 上有 Control,在左控制键上有 Escape 时,我收到以下错误:

% 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

这是失败的代码:

remove Lock = Caps_Lock

! ESC
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

如果我注释掉以add或开头的所有行,remove它会正常运行,但不会执行我想要的操作。

程序版本(Gentoo x86(稳定)):

  • xorg-服务器-1.7.6
  • xmodmap-1.0.4
  • xf86-输入-evdev-2.3.2

Xorg.conf:

# 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"
EndSection
Section "Module"
    Disable "dri"
    Disable "dri2"
EndSection

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"
EndSection

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"
EndSection

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"
EndSection

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

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

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

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

更新之前一切正常。

答案1

大多数情况下,当我收到此错误时,是因为我尝试将一个键符号分配给修饰符,但该键符号已用于其他修饰符。尝试运行“xmodmap -pm”并验证您尝试分配给修饰符的键符号尚未被使用。

例如,如果 Meta_L 已分配给 mod4,那么如果您尝试将 Meta_L 分配给 mod1 而不先将其从 mod4 中删除,则可能会出现此错误。

答案2

根据Xmodmap 手册,您似乎遗漏了至少一个关键步骤。您不仅必须“删除”修饰键位分配,还必须“清除”修饰键组中的键。

是的,我知道这确实令人困惑!

这些任务/命令似乎也必须按照特定的顺序运行:

  1. 删除/清除组和键的分配
  2. 将键盘符号分配给所需的键码
  3. 将键盘符号添加到适当的修饰符组

我看到这个帖子已经有一段时间没有活动了,显然已经死了(原作者已经解决或放弃了这个问题)。但希望这个澄清可以帮助其他遇到类似情况的人。

相关内容