Henry Poon's Blog

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

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Next Post

Previous Post

7 Comments

  1. Ben S. 2015-08-23

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

    • henrypoon 2015-08-25 — Post Author

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

      • Ben S. 2015-08-28

        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.

        • Ben S. 2015-08-28

          Update: Well it’s reporting the properties now, so I’ll have to play some more.

          • henrypoon 2015-09-03 — Post Author

            What was wrong?

          • Ben S. 2015-09-03

            No idea. Seems to be working now, thanks.

  2. Acceptance 2016-12-28

    Thank you for this easy solution!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© 2024 Henry Poon's Blog

Theme by Anders Norén