鼠标加速
禁用鼠标加速
使用 Xorg,libinput 将自身设置为默认驱动,配置文件为 /usr/share/X11/xorg.conf.d/40-libinput.conf
。要为我们的指针设备激活 flat
配置文件,我们需要将 flat
配置文件设置为 1
,并将 adaptive
和 custom
配置文件选项设置为 0
。
找出您的设备 ID
# xinput
第一个数字表示默认加速配置文件,第二个数字表示 flat 配置文件(无加速),第三个数字表示自定义配置文件。要激活 flat 配置文件
# xinput set-prop "deviceid" "libinput Accel Profile Enabled" 0 1 0
确认更改
# xinput list-props "deviceid"
通过将选项添加到指针部分使其持久化
/etc/X11/xorg.conf.d/40-libinput.conf
Section "InputClass" Identifier "libinput pointer catchall" MatchIsPointer "on" MatchDevicePath "/dev/input/event*" Driver "libinput" Option "AccelProfile" "flat" EndSection
在 GDM 中禁用鼠标加速
在 GDM 中使用 Wayland 禁用鼠标加速
sudo -u gdm dbus-launch gsettings set org.gnome.desktop.peripherals.mouse accel-profile 'flat'
配置鼠标加速
设置鼠标加速取决于您正在使用的窗口协议:Xorg 或 Wayland。
- 在 Xorg 上,有几种设置鼠标加速的方法
- 通过编辑 Xorg 配置文件
- xorg-xset 和 xorg-xinput,它们分别提供 xset 和 xinput
- 以及 桌面环境 中常见的配置界面。
- 如果您正在使用 Wayland,则事件由 libinput 控制。合成器的工作是公开 libinput 带来的设置。目前还没有跨合成器更改设置的标准方法。[1]
- GNOME 自行管理鼠标加速。可以通过安装 dconf-editor 并编辑 org/gnome/desktop/peripherals/mouse/acceleration-profile 中的值来选择 “adaptive” 和 “flat” 配置文件。或者,gnome-tweaks 也可以用于编辑 org/gnome/desktop/peripherals/mouse/acceleration-profile。
使用 libinput 的鼠标加速
当使用自适应指针加速配置文件时,libinput 根据 DPI 和参数 Acceleration Speed
[2] 计算鼠标加速。 libinput 依赖于 evdev [3] 报告的分辨率。使用 xset m
设置的反馈设置实际上被忽略。当使用 flat 指针加速配置文件时,加速度因子是恒定的,与指针的速度无关。这在设备和屏幕上的指针之间提供 1:1 的移动。
更改加速度
使用 xinput list
查找您的设备 ID,并使用以下命令设置加速度速度。请注意,加速度速度必须在 [-1,1] 范围内。查看此图以查看不同加速度速度值的影响。
$ xinput --set-prop <device id> 'libinput Accel Speed' <acceleration factor>
使用以下命令确认您的更改
$ xinput --list-props <device id>
持久化配置
libinput 不存储配置选项,它由调用者来管理这些选项。在 Wayland 下,配置由桌面环境恢复。在 X 下,xf86-input-libinput 读取 xorg 配置文件并应用选项 [4]。要在 X 下使更改持久化,请创建如下文件
/etc/X11/xorg.conf.d/99-libinput-custom-config.conf
Section "InputClass" Identifier "<something to identify this snippet>" MatchDriver "libinput" MatchProduct "<substring of the device name>" Option "AccelSpeed" "<e.g. 0.3>" EndSection
有关更多选项,请参见 libinput(4)。
设置鼠标加速
在 Xorg 配置文件中
有关详细信息,请参见 xorg.conf(5)。
示例
/etc/X11/xorg.conf.d/50-mouse-acceleration.conf
Section "InputClass" Identifier "My Mouse" MatchIsPointer "yes" # set the following to 1 1 0 respectively to disable acceleration. Option "AccelerationNumerator" "2" Option "AccelerationDenominator" "1" Option "AccelerationThreshold" "4" EndSection
/etc/X11/xorg.conf.d/50-mouse-deceleration.conf
Section "InputClass" Identifier "My Mouse" MatchIsPointer "yes" # some curved deceleration # Option "AdaptiveDeceleration" "2" # linear deceleration (mouse speed reduction) Option "ConstantDeceleration" "2" EndSection
您还可以通过在类节中使用 “MatchProduct”、“MatchVendor” 和其他匹配项,将设置分配给特定硬件。运行 lsusb
以找出要匹配的产品名称和供应商
$ lsusb -v | grep -e idProduct -e idVendor
如果您无法识别您的设备,请尝试运行 xinput list
。一些使用 Logitech Unifying Recceiver 的设备共享相同的 USB 连接,因此,鼠标不会在使用 lsusb
时出现
使用 xinput
首先,获取已插入设备的列表(忽略任何虚拟指针)
$ xinput list
记下 ID。如果 ID 容易更改,您也可以在命令中使用完整名称。
获取可用于修改的可用属性及其当前值的列表,使用
$ xinput list-props 9
其中 9
是您希望使用的设备的 ID。或者
$ xinput list-props "mouse name"
其中 mouse name
是您的鼠标名称,由 xinput list
给出。
示例,将 Constant Deceleration
的属性更改为 2
$ xinput list-props 9
Device 'mouse name': Device Enabled (121): 1 Device Accel Profile (240): 0 Device Accel Constant Deceleration (241): 1.000000 Device Accel Adaptive Deceleration (243): 1.000000 Device Accel Velocity Scaling (244): 10.000000
$ xinput --set-prop "mouse name" "Device Accel Constant Deceleration" 2
为了使其永久生效,请编辑 Xorg 配置(见上文)或将命令添加到 xprofile。后者不会影响显示管理器中的速度。
配置示例
您可能需要使用多种方法来实现您想要的鼠标设置。以下是我配置通用光学鼠标所做的工作:首先,将默认移动速度降低 3 倍,使其更精确。
$ xinput --set-prop 9 'Device Accel Constant Deceleration' 3 &
然后,启用加速,并在移动超过 6 个单位后使其速度提高 3 倍。
$ xset mouse 3 6 &
如果您对结果感到满意,请将前面的命令存储在 ~/.xinitrc
中。