禁用滑鼠加速度
使用 Xorg,Arch Linux 將 libinput 設置為默認驅動,位於
"/usr/share/X11/xorg.conf.d/40-libinput.conf"
為了激活我們的指針設備的flat
(平坦)配置文件,我們需要將 flat
設置為 1
,並將 adaptive
(自適應)和 custom
(自定義)配置文件選項設置為 0
。
找出您的設備 ID。
# xinput
第一個數字表示默認的加速度配置文件,第二個數字表示平坦配置文件(無加速度),第三個數字表示自定義配置文件。要激活平坦配置文件:
# xinput set-prop "deviceid" "libinput Accel Profile Enabled" 0 1 0
確認更改:
# xinput list-props "deviceid"
通過在 /usr/share/X11/xorg.conf.d/40-libinput.conf
中的指針部分添加選項來使其持久化。
/usr/share/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
配置滑鼠加速度
設置滑鼠加速度取決於您使用的窗口協議: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 依賴於 xf86-input-evdev包 [3] 報告的解析度。使用 xset m
設置的反饋設置實際上被忽略了。當使用平坦指針加速度配置文件時,加速度因子是恆定的,不論指針的速度如何。這提供了設備和屏幕上指針之間的 1:1 移動比例。
更改加速度
使用 xinput list
查找您的設備 ID,並使用以下命令設置加速度。請注意,加速度必須在 [-1,1] 的範圍內。查看這個圖表以了解不同加速度值的影響。
$ xinput --set-prop <device id> 'libinput Accel Speed' <acceleration factor>
使用以下命令確認您的更改:
$ xinput --list-props <device id>
持久化配置
libinput 本身不存儲配置選項,由調用者管理這些配置。在 Wayland 下,桌面環境會恢復配置。在 Xorg 下,xf86-input-libinput包 讀取 Xorg 配置文件並應用選項 [4]。為了在 Xorg 下使更改持久化,可以創建如下的配置文件:
/etc/X11/xorg.conf.d/99-libinput-custom-config.conf
Section "InputClass" Identifier "<用於標識此片段的名稱>" MatchDriver "libinput" MatchProduct "<設備名稱的子字符串>" Option "AccelSpeed" "<例如 0.3>" EndSection
更多選項請參見 libinput(4)。
設置滑鼠加速度
在 Xorg 配置中
詳見 xorg.conf(5)。
示例:
/etc/X11/xorg.conf.d/50-mouse-acceleration.conf
Section "InputClass" Identifier "我的滑鼠" MatchIsPointer "yes" # 分別設置為 1 1 0 以禁用加速度。 Option "AccelerationNumerator" "2" Option "AccelerationDenominator" "1" Option "AccelerationThreshold" "4" EndSection
/etc/X11/xorg.conf.d/50-mouse-deceleration.conf
Section "InputClass" Identifier "我的滑鼠" MatchIsPointer "yes" # 一些曲線減速 # Option "AdaptiveDeceleration" "2" # 線性減速(滑鼠速度降低) Option "ConstantDeceleration" "2" EndSection
您也可以通過在類部分中使用MatchProduct
、MatchVendor
等匹配項來為特定硬體分配設置。運行 lsusb
來找出要匹配的產品名稱和供應商:
$ lsusb -v | grep -e idProduct -e idVendor
如果您無法識別您的設備,嘗試運行 xinput list
。一些使用羅技優聯接收器的設備共享相同的 USB 連接,因此滑鼠在使用 lsusb
時可能不出現。
使用 xinput
首先,獲取已連接設備的列表(忽略任何虛擬指針):
$ xinput list
記下設備 ID。如果 ID 容易變化,也可以在命令中使用設備全名。
使用以下命令獲取可修改的屬性及其當前值的列表:
$ xinput list-props 9
其中 9
是您要使用的設備的 ID。或者
$ xinput list-props "鼠标名称"
其中 滑鼠名稱
是由 xinput list
提供的滑鼠名稱。
例如,將 Constant Deceleration
屬性更改為 2:
$ xinput list-props 9
Device '滑鼠名稱': 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 "鼠标名称" "Device Accel Constant Deceleration" 2
要使其永久生效,編輯 Xorg 配置文件(見上文)或將命令添加到 xprofile。後者不會影響在顯示管理器中的速度。
配置示例
您可能需要使用不止一種方法來實現您想要的滑鼠設置。以下是我為一個通用光學滑鼠配置的步驟: 首先,將默認移動速度減慢 3 倍,使其更精確。
$ xinput --set-prop 9 'Device Accel Constant Deceleration' 3 &
然後,啟用加速度,並在移動超過 6 個單位後使其速度提高 3 倍。
$ xset mouse 3 6 &
如果您對結果滿意,將上述命令存儲在 ~/.xinitrc
中。