Locate the id of input device and change the value of its property

Solution 1:

From the xinput man page:

device can be the device name as a string or the XID of the device.

It means that you can just give the full name of your mouse to the xinput command.

Let's first identify your mouse device, type xinput in a terminal:

$ xinput 
⎡ Virtual core pointer                      id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad                id=17   [slave  pointer  (2)]
⎜   ↳ Logitech Logitech Illuminated Keyboard    id=11   [slave  pointer  (2)]
⎜   ↳ ROCCAT ROCCAT Kone Pure Optical           id=13   [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)]
    ↳ Sleep Button                              id=8    [slave  keyboard (3)]
    ↳ HD Pro Webcam C920                        id=9    [slave  keyboard (3)]
    ↳ Integrated Camera                         id=15   [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard              id=16   [slave  keyboard (3)]
    ↳ ThinkPad Extra Buttons                    id=18   [slave  keyboard (3)]
    ↳ Logitech Logitech Illuminated Keyboard    id=10   [slave  keyboard (3)]
    ↳ ROCCAT ROCCAT Kone Pure Optical           id=12   [slave  keyboard (3)]
    ↳ No brand 2Port KVMSwicther                id=14   [slave  keyboard (3)]

Here my mouse is a ROCCAT ROCCAT Kone Pure Optical but you can't use it as is because this type of mouse declares several devices (a gaming mouse).

So prefix the device name with 'pointer:' as follow:

$ xinput --set-prop 'pointer:ROCCAT ROCCAT Kone Pure Optical' "Device Accel Constant Deceleration" 4

Adjust the above command to match your own device and you can paste it in your mouse.sh script.