Disabling Mouse Acceleration in Ubuntu

I’ve been quite accustomed to disabling mouse acceleration on my Windows machine (thanks to playing massive amounts of Counter-Strike back in the day), but now that I’ve started to use Linux a bit more, I’ve found that disabling mouse acceleration was not as easy as in Windows.

Script

I’ve managed to produce a script to disable mouse acceleration (works for me on Ubuntu 14.04).  However, this script needs to be run every time the computer boots because the settings don’t stay.  Here is the script:

#wait for the desktop to settle
sleep 5

#gets the hardware id's of all mice plugged into the system
hardwareIds=$(xinput | grep -i mouse | awk '{print substr($(NF-3),4)}')

#turn off mouse acceleration
for i in $hardwareIds
do
xinput set-prop ${i} 'Device Accel Profile' -1
xinput set-prop ${i} 'Device Accel Velocity Scaling' 1
done

Explanation

The script works by extracting the hardware id’s of the mice that are connected to the system and then applying properties to them that disable mouse acceleration for that device.  The extraction of the mouse hardware id’s are done with this:

#gets the hardware id's of all mice plugged into the system
hardwareIds=$(xinput | grep -i mouse | awk '{print substr($(NF-3),4)}')

Calling xinput in the Terminal will list all the connected input devices, which is grepped (case insensitively) for the word “mouse”, which gives something like this on my machine:

⎜ ↳ Logitech G500s Laser Gaming Mouse id=14 [slave pointer (2)]
⎜ ↳ Logitech G500s Laser Gaming Mouse id=15 [slave pointer (2)]

The call to awk extracts the hardware id from those two lines (14, 15 in the above case) and stores them in an array that is iterated through when setting the mouse properties.

Reference

This is the website that showed me how to disable mouse acceleration to begin with: http://ubuntuforums.org/showthread.php?t=1734400

7 Comments

  1. Isn’t there some way to put this in xorg.conf?

    • henrypoon

      August 25, 2015 at 10:05

      I can’t say I know much about xorg.conf, but I don’t see why not. Did you have success with it?

      • I wouldn’t know how to translate what you’re doing to xorg.conf settings.

        I’ve tried some xorg.conf settings posted elsewhere but they don’t work.

        Your method actually doesn’t work for me either, because xinput reports that my mouse doesn’t have those properties for some reason.

  2. Thank you for this easy solution!

Leave a Reply

© 2017 Henry Poon's Blog

Theme by Anders NorénUp ↑

%d bloggers like this: