3

I learned from this post that you can set mouse speed by the following:

$ xinput --set-prop 10 "Device Accel Constant Deceleration" 4

where 10 is the id of the target device, which you can obtain by checking the output of xinput command.

However, I problem is that every time I unplug my mouse and re-plug it, its id changes. Thus simply putting the line above into a mouse.sh isn't sufficient. I need also to dynamically search for the current id value of the target device, i.e., my mouse.

The tragic part is that I know nothing at all about bash script, and thus here to seek for a quick fix for my specific problem:

How to write this simple script to locate the id of an input device, say mouse, and use this id in the xinput line above?

1 Answer 1

2

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.

1
  • That's really convenient. Thanks for the nice solution. Especially for the pointer: part.
    – Naitree
    Commented Jan 12, 2015 at 10:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .