Last active
April 28, 2016 08:04
-
-
Save JonasGroeger/bbc95934624da0409eb4 to your computer and use it in GitHub Desktop.
Script to disable the mouse acceleration on Ubuntu (and probably other distributions).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| ################################################################################ | |
| # Description # | |
| # Script to disable the mouse acceleration on Ubuntu (and probably other # | |
| # distributions). # | |
| # # | |
| # Author # | |
| # Jonas Gröger <[email protected]> # | |
| # # | |
| # Date (date -R) # | |
| # Sun, 04 Jan 2015 18:42:52 +0100 # | |
| # # | |
| # Tested on # | |
| # Ubuntu 14.10. # | |
| # # | |
| # Usage # | |
| # Supply this script with the input-ids of your mouse. You can obtain them # | |
| # using the 'xinput' command and looking for your mouse there. You may # | |
| # have more than one id. # | |
| # # | |
| # Then, add the script to your autostart and supply it with # | |
| # one or more ids: # | |
| # # | |
| # /path/to/script/disable-mouse-accel.sh 8 1 # | |
| # # | |
| # This will stop the mouse acceleration for devices 8 and 1. It allows for # | |
| # multiple ids because some mouses have multiple and some people have more # | |
| # than one mouse simultaneously. # | |
| # # | |
| ################################################################################ | |
| # Exit on error | |
| set -e | |
| ########################## | |
| # Helper functions # | |
| ########################## | |
| # Returns 0 if $1 is a number. Returns 1 otherwise. | |
| is_number() { | |
| case "$1" in | |
| ''|*[!0-9]*) return 1 ;; | |
| *) return 0 ;; | |
| esac | |
| } | |
| ########################## | |
| # Main application logic # | |
| ########################## | |
| if [ $# -eq 0 ] | |
| then | |
| echo "Usage: ./disable-mouse-accel.sh <device-id> [<device-id>...]" | |
| exit 126 | |
| fi | |
| # Loop through all the input arguments (space separated) | |
| for id in "$@" | |
| do | |
| # If we have a valid input device id | |
| if is_number $id | |
| then | |
| # Disable the accelerator profile, see: http://superuser.com/a/260131 | |
| xinput --set-prop $id "Device Accel Profile" -1 | |
| echo -e "\e[32m[\u2713 ]\e[0m Disabled acceleration for device $1." | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment