我的鼠标有一个不幸的功能。在左侧,当我使用它时,我的拇指非常轻柔地坐在右侧,有两个按钮非常敏感,只需刷子就可以使它们点击。
我当然是在谈论讨厌的前进/后退按钮,如果在浏览器中按下这些按钮,就会使观看长达一小时的 YouTube 视频变得更加困难。有没有办法让我禁用它们?这会由 X 处理吗?
Gil*_*il' 55
xev在终端中启动程序。在xev窗口内移动鼠标;你会看到很多东西滚动。依次按下每个按钮。然后切换回终端窗口并按Ctrl+ C。xev表示输入事件的描述,尤其是ButtonPress和ButtonRelease鼠标点击(你也看到了一些MotionNotify鼠标移动和其他活动)。
您的前进和后退按钮很可能映射到鼠标按钮,可能是按钮 8 和 9:
ButtonPress event, serial 29, synthetic NO, window 0x2e00001,
    root 0x105, subw 0x0, time 2889100159, (166,67), root:(1769,98),
    state 0x0, button 8, same_screen YES
Run Code Online (Sandbox Code Playgroud)
如果是这种情况,请尽可能将这些按钮重新映射到浏览器中的不同操作。或者,您可以将按钮重新映射到浏览器不会响应的不同按钮编号,或者在系统级别完全禁用按钮。为此,请将这些行放在名为 的文件中~/.Xmodmap:
! Remap button 8 to 10 and disable button 9.
pointer = 1 2 3 4 5 6 7 10 0
Run Code Online (Sandbox Code Playgroud)
用命令测试它xmodmap ~/.Xmodmap。大多数桌面环境和窗口管理器会在您登录时自动运行此命令;如果没有,请安排它在 X 启动时运行。
当您按下这些按钮时,您的鼠标也有可能发送键盘事件:
KeyPress event, serial 32, synthetic NO, window 0x2e00001,
    root 0x105, subw 0x0, time 2889100963, (957,357), root:(2560,388),
    state 0x0, keycode 166 (keysym 0x1008ff26, XF86Back), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False
Run Code Online (Sandbox Code Playgroud)
在这种情况下,将这些行放入~/.Xmodmap:
keycode 166 = NoSymbol
keycode 167 = NoSymbol
Run Code Online (Sandbox Code Playgroud)
        只是一个快速命令来修复它,与其他答案没有什么不同:
xmodmap -e "pointer = 1 2 3 4 5 6 7 0 0 0 0 0 0" #the fix
测试
xmodmap -pp # check the changes
xterm -e xev # test the nullified buttons
# to restore in case you are going to play some game that uses them
xmodmap -e "pointer = 1 2 3 4 5 6 7 8 9 10 11 12 13"
Run Code Online (Sandbox Code Playgroud)
您可以将修复cmd放在启动应用程序中。
更好的方法是使用 xdotool 检查活动窗口是否是您的任何浏览器,并根据需要调用 xmodmap 来禁用/启用它,但这需要一些脚本编写:>
我认为没有理由让 7 以上的按钮保持启用状态,有什么原因吗?