Tuesday, December 25, 2012

Wireless Mouse Too Sensitive in Linux Desktop (Cinnamon)

One reason I love (with tears in my eyes) Linux is how absolutely RIDICULOUSLY customizable it is.

My wife got me a generic wireless mouse for Christmas.  The brand name is "Gear Head" and it is (of course) made in China and she told me it was pretty inexpensive.  I had a *slight* doubt that I would have to mess around with it a little to get it to work on the Linux desktop.  To my surprise, I plugged in the little USB wireless dongle and the mouse just started working immediately!

Unfortunately, the first thing I noticed was that the mouse was way too sensitive for my liking.  Pretty simple fix though, right?  In Cinnamon, just go to System Settings --> Mouse and Touchpad --> Power Speed...  hm, sensitivity and acceleration are both set to the minimum values.  Now what?

I found this question on ubuntuforums.org, which basically has the question and the answer, although the original poster was trying to change properties for an ambiguous device.  Here is another way to do it:

wskellenger@marquette ~ $ xinput list
⎡ Virtual core pointer                     id=2 [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer               id=4 [slave  pointer  (2)]
⎜   ↳ DualPoint Stick                          id=12 [slave  pointer  (2)]
⎜   ↳ AlpsPS/2 ALPS DualPoint TouchPad         id=13 [slave  pointer  (2)]
⎜   ↳  2.4G RF MOUSE                           id=15 [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)]
    ↳ Power Button                             id=8 [slave  keyboard (3)]
    ↳ Sleep Button                             id=9 [slave  keyboard (3)]
    ↳ Laptop_Integrated_Webcam_HD              id=10 [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard             id=11 [slave  keyboard (3)]
    ↳ Dell WMI hotkeys                         id=14 [slave  keyboard (3)]
wskellenger@marquette ~ $ 
 
In my case the 2.4G RF Mouse is the culprit.  Here we can investigate the properties of the device (note it is device id 15):

wskellenger@marquette ~ $ xinput --list-props 15
Device ' 2.4G RF MOUSE':
 Device Enabled (133): 1
 Coordinate Transformation Matrix (135): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
 Device Accel Profile (254): 0
 Device Accel Constant Deceleration (255): 1.000000
 Device Accel Adaptive Deceleration (256): 1.000000
 Device Accel Velocity Scaling (257): 10.000000
 Device Product ID (250): 9781, 1537
 Device Node (251): "/dev/input/event13"
 Evdev Axis Inversion (258): 0, 0
 Evdev Axes Swap (260): 0
 Axis Labels (261): "Rel X" (143), "Rel Y" (144), "Rel Vert Wheel" (555)
 Button Labels (262): "Button Left" (136), "Button Middle" (137), "Button Right" (138), "Button Wheel Up" (139), "Button Wheel Down" (140), "Button Horiz Wheel Left" (141), "Button Horiz Wheel Right" (142), "Button Side" (681), "Button Extra" (682), "Button Unknown" (253), "Button Unknown" (253), "Button Unknown" (253), "Button Unknown" (253)
 Evdev Middle Button Emulation (263): 0
 Evdev Middle Button Timeout (264): 50
 Evdev Third Button Emulation (265): 0
 Evdev Third Button Emulation Timeout (266): 1000
 Evdev Third Button Emulation Button (267): 3
 Evdev Third Button Emulation Threshold (268): 20
 Evdev Wheel Emulation (269): 0
 Evdev Wheel Emulation Axes (270): 0, 0, 4, 5
 Evdev Wheel Emulation Inertia (271): 10
 Evdev Wheel Emulation Timeout (272): 200
 Evdev Wheel Emulation Button (273): 4
 Evdev Drag Lock Buttons (274): 0

Now I just changed the "Device Accel Constant Deceleration" property like so:

wskellenger@marquette ~ $ xinput --set-prop 15 "Device Accel Constant Deceleration" 2

Perfect.

Update 29-Dec-2012:

To get this behavior on every startup, I've created a simple shell script:

#!/bin/bash
# ----- Set mouse decel for wireless mouse if present -----
DEVID=`xinput list | grep "RF MOUSE" | sed -e "s/^.*id=\([0-9]\+\).*/\1/"`
if [ "$DEVID" != "" ]; then
   xinput --set-prop $DEVID "Device Accel Constant Deceleration" 2
   echo Set device deceleration for device $DEVID.
fi

The script basically just does exactly what I described above -- it looks for "RF MOUSE" in the input list.  If it is found, it determines the ID number of the device and stores that number into a variable called DEVID.  Then, if the DEVID isn't empty, it runs the xinput --set-prop command.

I put this into a script file called myxinit.sh and I copied this into my ~/bin directory.   Make sure to set this file as executable with "chmod +x myxinit.sh"

Now you can set this to run when Cinnamon starts up, simply by going to Preferences --> Startup Applications:


And then in the Startup Applications dialog, add the script:


Optional: If this helped you, click one of my ads!  :-)

2 comments:

  1. I can't seem to get the shell script to work.
    I am on Linux Mint 17.2 Cinnamon.
    However the manual way does work.
    Any advice?

    ReplyDelete