3

How do you configure xinput to set multiple devices automatically using a script?

 $ xinput --list ⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ AlpsPS/2 ALPS GlidePoint id=12 [slave pointer (2)] ⎜ ↳ ALPS PS/2 Device id=13 [slave pointer (2)] ⎜ ↳ Corsair Corsair M65 Gaming Mouse id=15 [slave pointer (2)] ⎜ ↳ Corsair Corsair M65 Gaming Mouse id=17 [slave pointer (2)] ⎣ Virtual core keyboard id=3 [master keyboard (2)] ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] ↳ Power Button id=6 [slave keyboard (3)] ↳ Video Bus id=7 [slave keyboard (3)] ↳ Power Button id=8 [slave keyboard (3)] ↳ Sleep Button id=9 [slave keyboard (3)] ↳ Laptop_Integrated_Webcam_HD id=10 [slave keyboard (3)] ↳ AT Translated Set 2 keyboard id=11 [slave keyboard (3)] ↳ Dell WMI hotkeys id=14 [slave keyboard (3)] ↳ Corsair Corsair M65 Gaming Mouse id=16 [slave keyboard (3)] 

And the problem is both of these "corsair gaming mouse" have different IDs every time. I don't know why there are two mouses... but that's the world I live in. How do I write a script to set the properties on both of them? I used this, but it didn't work the next time I booted (ID changed):

#!/bin/sh xinput --set-pr op 10 "Device Accel Profile" 6 xinput --set-prop 10 "Device Accel Velocity Scaling" 5 xinput --set-prop 10 "Device Accel Constant Deceleration" 3 #xinput --set-prop 10 "Device Accel Velocity Tracker Count" 2 

I had tried using the name, but it complains there are multiple matching devices.

Any help is appreciated.

1
  • There are multiple instances because your mouse if capable of having different "profiles". For example, I have a profile for CS:GO and a profile for normal computer usage. Each has profile has different polling and sensitivity etc.. Commented Dec 1, 2015 at 20:32

2 Answers 2

5

If you are need to make changes to both you can use loop

#!/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 
0

You can add a "pointer:" or "keyboard:" in front of the name. For example

xinput list-props 'pointer:Logitech M585/M590' xinput list-props 'keyboard:Logitech M585/M590' 
1
  • This doesn't work when there are multiple devices of same type and name (as in the example given above). It fails with: Warning: There are multiple devices matching 'pointer:...'. Commented Nov 20, 2020 at 9:48

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.