如何使用xinput通过脚本配置多个设备?

Exa*_*eta 3 linux xorg mouse xinput

如何配置 xinput 以使用脚本自动设置多个设备?

\n\n
    $ xinput --list\n\xe2\x8e\xa1 Virtual core pointer                      id=2    [master pointer  (3)]\n\xe2\x8e\x9c   \xe2\x86\xb3 Virtual core XTEST pointer                id=4    [slave  pointer  (2)]\n\xe2\x8e\x9c   \xe2\x86\xb3 AlpsPS/2 ALPS GlidePoint                  id=12   [slave  pointer  (2)]\n\xe2\x8e\x9c   \xe2\x86\xb3 ALPS PS/2 Device                          id=13   [slave  pointer  (2)]\n\xe2\x8e\x9c   \xe2\x86\xb3 Corsair Corsair M65 Gaming Mouse          id=15   [slave  pointer  (2)]\n\xe2\x8e\x9c   \xe2\x86\xb3 Corsair Corsair M65 Gaming Mouse          id=17   [slave  pointer  (2)]\n\xe2\x8e\xa3 Virtual core keyboard                     id=3    [master keyboard (2)]\n    \xe2\x86\xb3 Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]\n    \xe2\x86\xb3 Power Button                              id=6    [slave  keyboard (3)]\n    \xe2\x86\xb3 Video Bus                                 id=7    [slave  keyboard (3)]\n    \xe2\x86\xb3 Power Button                              id=8    [slave  keyboard (3)]\n    \xe2\x86\xb3 Sleep Button                              id=9    [slave  keyboard (3)]\n    \xe2\x86\xb3 Laptop_Integrated_Webcam_HD               id=10   [slave  keyboard (3)]\n    \xe2\x86\xb3 AT Translated Set 2 keyboard              id=11   [slave  keyboard (3)]\n    \xe2\x86\xb3 Dell WMI hotkeys                          id=14   [slave  keyboard (3)]\n    \xe2\x86\xb3 Corsair Corsair M65 Gaming Mouse          id=16   [slave  keyboard (3)]\n
Run Code Online (Sandbox Code Playgroud)\n\n

问题是这两个“海盗船游戏鼠标”每次都有不同的 ID。我不知道为什么有两只鼠标...但这就是我生活的世界。如何编写脚本来设置它们的属性?我用了这个,但是下次启动时它不起作用(ID改变了):

\n\n
#!/bin/sh\nxinput --set-pr\nop 10 "Device Accel Profile" 6\nxinput --set-prop 10 "Device Accel Velocity Scaling" 5\nxinput --set-prop 10 "Device Accel Constant Deceleration" 3\n#xinput --set-prop 10 "Device Accel Velocity Tracker Count" 2\n
Run Code Online (Sandbox Code Playgroud)\n\n

我曾尝试使用该名称,但它抱怨有多个匹配的设备。

\n\n

任何帮助表示赞赏。

\n

Cos*_*tas 5

如果您需要对两者进行更改,可以使用循环

#!/bin/sh
for id in $(xinput --list | \
            sed -n '/Corsair Corsair M65 Gaming Mouse.*pointer/s/.*=\([0-9]\+\).*/\1/p')
do
  xinput --set-prop $id "Device Accel Profile" 6
  ...
  whatever you want to do
  ...
done
Run Code Online (Sandbox Code Playgroud)