xinput
xinput 是一个用于配置和测试 X 输入设备的实用程序,例如鼠标、键盘和触摸板。它可以在 xorg-xinput 软件包中找到。
用法
列出设备
要列出可用的 xinput 设备,请使用
$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ DELL0ABC:DE F123:4567 Mouse id=9 [slave pointer (2)] ⎜ ↳ DELL0ABC:DE F123:4567 Touchpad id=10 [slave pointer (2)] ⎜ ↳ PS/2 Generic Mouse id=16 [slave pointer (2)] ⎣ Virtual core keyboard id=3 [master keyboard (2)] ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] ↳ Video Bus id=6 [slave keyboard (3)] ↳ Power Button id=7 [slave keyboard (3)] ...
设备
可以通过其名称 ("DELL0ABC:DE F123:4567 Touchpad"
) 或 ID (10
) 来标识。
当在启动脚本中执行时,建议您使用名称,因为 ID 可能会在重启后更改并导致不一致。
列出属性
要列出设备可以设置的所有属性,请使用以下命令
$ xinput list-props device
这可能会产生如下结果
$ xinput list-props "DELL0ABC:DE F123:4567 Touchpad"
Device 'DELL0ABC:DE F123:4567 Touchpad': Device Enabled (179): 1 Coordinate Transformation Matrix (181): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000 libinput Tapping Enabled (336): 0 libinput Tapping Enabled Default (337): 0 libinput Tapping Drag Enabled (338): 1 libinput Tapping Drag Enabled Default (339): 1 ...
每个 属性
可以使用其名称 ("libinput Tapping Enabled"
) 或编号 (336
) 来标识。
与设备一样,建议在启动脚本中使用名称,因为 ID 可能会更改,尽管频率较低。
设置设备属性
设备的属性可以设置为一个或多个(最多三个)值。将属性设置为值的语法是
$ xinput set-prop device property values
其中 values
替换为属性的值。
例如,要使用上述输出启用轻击。可以使用以下任一命令
$ xinput set-prop "DELL0ABC:DE F123:4567 Touchpad" "libinput Tapping Enabled" 1
或
$ xinput set-prop 10 338 1
成功后,不应产生任何输出。
使用示例
以下是 xinput 可以使用的一些方法。
移除鼠标中键和右键
$ xinput set-button-map mouse-device 1 1 1
上述命令将使鼠标中键和右键的功能类似于左键。设置为零将禁用它们。
$ xinput set-button-map mouse-device 1 0 0