How to set mouse/trackpad speed with xinput

Any distro using Gnome comes with gnome-control-center, which includes a dandy GUI utility for setting mouse speed. Unfortunately, in the systems I’ve primarily run (Debian and Ubuntu) I’ve not found it to be effective in any instance.
Every GUI app in GNU/Linux has CLI roots, right? So I found xinput and figured out how to use it.
First, run just


to get a list of all connected devices. Mine looked like this:

cortman's Pip-Boy ~$ xinput
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Logitech G500 id=10 [slave pointer (2)]
⎜ ↳ Logitech G500 id=11 [slave pointer (2)]
⎜ ↳ HID 0a5c:4503 id=15 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=17 [slave pointer (2)]
⎜ ↳ Microsoft Bluetooth Mobile Keyboard 6000 id=12 [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)]
↳ USB2.0 UVC WebCam id=9 [slave keyboard (3)]
↳ HID 0a5c:4502 id=14 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=16 [slave keyboard (3)]
↳ Toshiba input device id=18 [slave keyboard (3)]

The one I was interested in was the Logitech G500 gaming mouse. For some reason it has two ID’s. I have not looked into this or figured out why it does. I used #10, and all seemed to be working fine, so I didn’t explore further.

To change the sensitivity/acceleration, use the command

xinput --set-ptr-feedback

The syntax is as follows

xinput --set-ptr-feedback "device_id" accelNum accelDenom threshold

In my case I set it to

xinput --set-ptr-feedback "10" 30 5 2

As far as what these numbers actually signify, I’ll quote the man page:

By default the pointer (the on-screen representation of the pointing
device) will go `acceleration’ times as fast when the device travels
more than `threshold’ mickeys (i.e. would-be pixels) in 10 ms, includ‐
ing a small transition range. This way, the pointing device can be used
for precise alignment when it is moved slowly, yet it can be set to
travel across the screen in a flick of the wrist when desired. One or
both parameters for the m option can be omitted, but if only one is
given, it will be interpreted as the acceleration. If no parameters or
the flag ‘default’ is used, the system defaults will be set.

By this I take it that the first number (accelNum) is the actual speed number. At 10 my mouse was painfully slow; I think that’s pretty much the bottom of the threshold (but it doesn’t hurt to play around a bit).
The second number (accelDenom) is the multiplier used to calculate acceleration, i.e., the larger the number the faster it will accelerate relative to how fast you move the mouse suddenly.
The third number (threshold) tells, as the man page explains, how many pixels the device must move in a given time to accelerate.
Ways to make this persistent? As inelegant as it sounds, at this point it seems as though simply creating a script with this command and adding it to your startup programs is probably the simplest way to do it. I’ve seen talk of adding it to udev but they seem rather problematic. I may look into this more later.

I run Debian Wheezy, and that’s what I used to test and run this fix.

For any who’ve been frustrated by a lack of response from the GUI mouse tool, this is a pretty surefire way to fix it!