HOW TO LOWER MOUSE SENSITIVITY IN UBUNTU 12.04 OR IN ANY XSERVER DESKTOP
Im using Unity, and also XFCE (mostly XFCE as this laptop is under powered). I have a wireless HP mouse thats simply too sensitive, lowering the sensitivity settings via the Desktop Mouse Settings, does some good for lowering the speed; but simply not enough. This is where xinput comes in.
NOTE: this applies to anything that uses xinput, so any X11 window/desktop manager can benefit from this if your have a too-fast mouse
Steps
If dont have xinput (I noticed ubuntu had it but debian didnt):
apt-get install xinput
Open up a terminal like Xterm
# xinput or # xinput --list --short
Find your device id for me its 14, which is my HP wireless mouse.
# xinput list-props 14 or # xinput --list-props 14
NOTE: lots of the commands can have — prior or you can omit. The xinput –help shows that you dont need the –, but it works with and without
We need to change the value of “Device Accel Constant Deceleration” constant. By default for me its 1. Raising the value will make your mouse slower.
For me the sweet spot was 1.9, for others its 2.5. It depends on your preference and your mouse. The second you change the value, the change takes over.
SYNTAX: xinput set-prop <dev num> <property id or full name> <new value>
# xinput set-prop 14 "Device Accel Constant Deceleration" 2 or # xinput --set-prop 14 "Device Accel Constant Deceleration" 2
Also from list-props output we see that “Device Accel Constant Deceleration” has the ID of 261. So we can just change the value with id of the property.
This is how you would set it to 1.9 with the id:
# xinput set-prop 14 261 1.9 or # xinput --set-prop 14 261 1.9
NOTE: try numbers above 1 but below 3, above 3 might be too much. You can also try 1.9
To confirm your changes
# xinput list-props 14 or # xinput --list-props 14
Script to Automate Mouse Speed Setting
Here is a simple script to do the above (Read the comments to see how to use it):
NOTE: the below steps show you in detail how to make the script run at user login so that everyone gets the good speed – you can also just manually run it instead – also you can set it up (With extra research on your own part) to just make the script run for certain users (Just google, “xdg autostart start up scripts“).
NOTE TO MANUALLY RUN THE SCRIPT: First make sure you set the MOUSENAME variable in the script as described in all of the comments. Then do the following /etc/slow-mouse/slow-mouse.sh 2 , then try other numbers too besides 2 (note you can use decimal numbers like 1.5 or 1.9 etc…)
Put the script in a location where everyone everyone can access it:
# lets log in as root temporarily sudo -i # lets make the files and script in /etc/slow-mouse (They take up less space then anything so dont complain) mkdir /etc/slow-mouse cd /etc/slow-mouse touch slow-mouse.sh touch slow-mouse.desktop # since slow-mouse needs to be executable chmod +x slow-mouse.sh # run "xinput" and notice the name for your mouse, and pick a unique phrase that will identify your mouse. So if your mouse is called "HP Wireless Mobile Optical Mouse" then you can just pick "HP Wireless". When editing the script slow-mouse.sh, set the Variable MOUSENAME equal to that phrase. TIP: if you also have an HP Wireless Keyboard, then the word "HP Wireless" is not enough to uniquely identify your mouse, so instead pick something like "HP Wireless Mobile Optical Mouse" (the full name never hurts) vim slow-mouse.sh # Press i to type # Put (copy & paste if you will) the script from below in here # Dont forget to set the MOUSENAME variable as described in above comment # Press ESC :wq! ENTER to save and exit vim slow-mouse.desktop # Press i to type # Put (copy & paste if you will) the script from below in here # Press ESC :wq! ENTER to save and exit cd /etc/xdg/autostart # Make a symlink of the original slow-mouse.desktop to the "shortcut"/symlink in /etc/xdk/autostart/ (this folder contains everything that will autostart when a user logs in - you can also edit autostart items from a GUI - but I prefer CLI). The command below basically says take the file slow-mouse.desktop from the directory /etc/slow-mouse/ and make a symlink of it over here (Thats what the last dot is) ln -s /etc/slow-mouse/slow-mouse.desktop .
Here is the /etc/slow-mouse/slow-mouse.sh script
#!/bin/bash # WHAT THIS DOES: slow mouse speed further then mouse settings in X can # First prepare the script, its not fully automatic (yet): # names of mice can change from mouse to mouse. # so run "xinput" and find your mouse mine is called "HP Wireless", # and that uniquely identifies it, if I also had an "HP Wireless Keyboard" # then "HP Wireless" alone wouldnt uniquely identify it, # however "HP Wireless Mouse" will # So set the MOUSENAME variable below to match uniquely to your mousename # as seen from "xinput" output. # Usage: ./slow-mouse [decel constant] # 1 is default in systems and its too fast for some moutse # 2 is good for most, but you can tweak the number between 1.0 and 5.0 # to find your perfect number (im sure there is a cap above 5.0 for that num) # MOUSENAME="HP Wireless" # <---- change this variable to match mousename as seen from "xinput" output NEWS=$1 if [ -z $1 ] ; then NEWS=2 fi # find id of mouse, then set variable 261 to 2.0 for perfect slow default is 1 SED1=$(echo 's/.*'"${MOUSENAME}"'.*id=\([0-9][0-9]*\).*/\1/p') echo "Unique phrase for mouse name in 'xinput' output: $MOUSENAME" #exit 2 IDM=$(xinput | sed -n "$SED1") if [ -z $IDM ] ; then echo "- error: MOUSENAME variable didnt find the mouse, please edit the scripts MOUSENAME variable" echo "- You can use below output of xinput to help you choose the variable:" echo "- Running 'xinput' with a search/grep for mouse:" echo '# xinput | grep -i mouse' xinput | grep -i mouse echo "TIPS IN PICKING GOOD 'MOUSENAME' PHRASE/STRING:" echo "- first of all realize that the MOUSENAME variable will be used to _uniquely_ identify your mouse, so the name has to be matching only to the mouse and not to anything else" echo "- If your mouse is called 'HP Wireless Optical Mobile Mouse' then you can pick 'HP Wireless' for the MOUSENAME, or go all out and put 'HP Wireless Optical Wireless Mouse' - its important to match the case of the output displayed by xinput" echo "- Make sure the phrase/string you pick for MOUSENAME unique identifies only the mouse, ex: if I had a mouse called 'HP Wireless Mouse' and keyboard called 'HP Wireless Keyboard', then selecting 'HP Wireless' Would be too broad, so you would in this case select the MOUSENAME variable to be more specific like this'HP Wireless Mouse'" exit 1 fi echo "ID of mouse detected: $IDM" IDA=`xinput list-props 11 | grep Const | sed -n 's/^.*Dec.* (\([0-9]*\)).*$/\1/p'` echo "ID of 'Device Accel Constant Deceleration' is: $IDA" echo "Current setting of variable ${IDA}:" xinput list-props $IDM | grep ${IDA} echo "Setting 261 to $NEWS" xinput set-prop $IDM $IDA $NEWS echo "Confirming - should be ${NEWS}:" xinput list-props $IDM | grep ${IDA}
Here is the /etc/slow-mouse/slow-mouse.desktop script (That is symlinked tp /etc/xdk/autostart/slow-mouse.desktop):
[Desktop Entry] Name=slow-mouse Comment=Slow the mouse Exec=/etc/slow-mouse/slow-mouse.sh 2 Terminal=false Type=Application
Works in debian too. Just do: apt-get install xinput
Make sure to set the settings as a regular user not root.