Mouse Acceleration

Tuesday, Feb 23, 2021
#unix #tips #X11

Mouse acceleration is awful… Unless you’re using a trackpad, then it’s essential. Here’s how to make your trackpack accelerated while keeping your mice (mouses?) on a flat profile.

ls /etc/X11/xorg.conf.d/ will list your X11 configurations (some distros might change this path). Typically, these configurations will begin with a number. The files are loaded alphabetically so the numbers are just a clever way to set the load order. We just need to create a file named /etc/X11/xorg.conf.d/50-mouse-acceleration.conf with the following.

Section "InputClass"
	Identifier "My Mouse"
	MatchIsTouchpad "no"
	MatchIsPointer "yes"
	Option "AccelerationProfile" "-1"
	Option "AccelerationScheme" "none"
	Option "AccelSpeed" "-1"
EndSection

Breaking this down, we have an Identifier which is purely for your reference and doesn’t change anything (but is required for some reason?). Then we have two selectors, MatchIsTouchpad "no" and MatchIsPointer "yes". Basically, we’re telling X11 to apply this config to any device that isn’t a “Touchpad”, but is still a generic “Pointer” of some kind. This is perfect because it will match any random mouse we plug into our machine, but ignore the trackpad.

The last three options are a little weird AND there’s a newer alternative you could use instead.

Section "InputClass"
	Identifier "My Mouse"
	Driver "libinput"
	MatchIsTouchpad "no"
	MatchIsPointer "yes"
	Option "AccelProfile" "flat"
	Option "AccelSpeed" "0"
EndSection

The first method is a little bit of a hack (it will completely disable mouse acceleration, but it’s weird to read). The newer method might not work on weird old X11 installs so it’s good to be aware of both methods.

If for some reason this just isn’t working at all it’s probably because your trackpad isn’t properly being detected as a “trackpad”. You can just create more specific selectors, even down to having different “profiles” for your different mice if you wanted.

First you need to figure out some information about your input devices with the following command.

$ xinput list
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Synaptics TM2668-002                      id=12   [slave  pointer  (2)]
⎜   ↳ TPPS/2 IBM TrackPoint                     id=13   [slave  pointer  (2)]
⎜   ↳ Logitech M325                             id=14   [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)]
    ↳ Integrated Camera: Integrated C           id=9    [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard              id=10   [slave  keyboard (3)]
    ↳ ThinkPad Extra Buttons                    id=11   [slave  keyboard (3)]

Now you can print a huge slew of info about any of these with xinput list-props 14 (obviously replace 14 with the ID you want info about. In my case 14 dumps a big list of properties for my mouse. We can find all of xorg’s information about matching input devices in the INPUTCLASS SECTION of man 5 xorg.conf which you can read online here.

In my case I could use MatchProduct "Logitech" instead of MatchIsTouchpad "no" to select my wireless logitech mouse.