humpty promotes - Linux - Lubuntu

Lubuntu linux Tips
Setting your mouse speed
This is a quick way to setup your mouse speed.

The most basic device you need for using a desktop OS. Amazingly for years upon years now, Linux desktops have still managed to make it difficult for users to easily setup their newly bought high resolution pointers

You buy a new mouse. Plug it in and boot up your OS only to find the mouse too fast, too slow not 'feeling' quite right? You try the regular mouse adjuster panel but it makes no difference,. What to do?

The traditional way to set up a mouse is via xorg.conf. Since the new auto-detection scheme, the Ubuntu based distros have added /usr/share/X11/xorg.conf.d to the mix, as if it wasn't already difficult enough. It is basically the xorg.conf files that have been divided up into levels of execution.

But you can forget about xorg.conf (for the moment) as you can spend a long time hunting for compatible xorg.conf rules on the web and plenty of reboots before hitting upon the config that matches your device. When you finish (if at all) it will be christmas. Here I'll show you a faster method using xset and xinput.

xset and xinput

A combination of xset and xinput is a much easier method, and here's how it's done:

1. Open a terminal and type
xinput list --short

You'll get something like this;

⎡ Virtual core pointer                        id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                  id=4    [slave  pointer  (2)]
⎜   ↳ SIGMACHIP USB Keyboard                      id=9    [slave  pointer  (2)]
⎜   ↳ 2.4G Wireless Optical Mouse                 id=10    [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)]
    ↳ Power Button                                id=7    [slave  keyboard (3)]
    ↳ SIGMACHIP USB Keyboard                      id=8    [slave  keyboard (3)]
[2]+  Done                    leafpad upback  (wd: ~/utils)

And you can guess (in this case) the mouse device ID as 10.
You need this ID for xinput commands to config the mouse. (it will be different for yours).
An easy way to implement this is to create a script;

2. Create the script
>cd ~


# xset m <acc> <threshold>
  xset m 15/10 0
  xset q | grep acceleration
#xinput --set-ptr-feedback $ID 0 18 10    #(an alternative to xset m)


ID=`xinput list --short | grep -i $NAME | cut -f2 | cut -c4-| head -n1 `
echo $NAME Mouse ID is $ID

xinput --set-prop $ID "Device Accel Profile" 0
xinput --set-prop $ID "Device Accel Constant Deceleration" 2
xinput --set-prop $ID "Device Accel Adaptive Deceleration" 1
xinput --set-prop $ID "Device Accel Velocity Scaling" 5
xinput --list-props $ID | grep Accel

To run it, first make it executable;
>chmod 775
Then run it
> ./

xset m <acc> <threshold> sets the acceleration.
xinput is used to apply additonal behaviour.
The "ID=" line gets the device ID. You should replace the word 'Wireless' with a word you got from xinput list --short.

3. If you want to run this script every time you login, then see, < lubuntu-autostart >
Note that (depending on your lubuntu version) lxsession might still override both xorg and your autostart script. If this is the case, then to disable lxsession effects, comment out these lines in;



(and do not adjust the mouse settings in preferences>keyboard&mouse, as this will add back the entries)

Hot Tip for those who want to use lxsession settings;
Acceleration = AccFactor /10
Sensitivity = 110-

4. If you want to attach your script to a hotkey in openbox, then see here.

Advanced Tweaking

Use an xset  threshold of 0 (max sensitivity)  at first, then adjust this at the very end after all other things have been set. Threshold will fine tune small movements between close objects (text lines and chars).

Device Accel Profile

A "Device Accel Profile" of 0 will still enable the effects of "xset m <acc> <threshold>"
A "Device Accel Profile" of -1 will disable the effects of "xset m"

Any other value greater than 1 will still enable 'xset m' but also apply a predefined scheme. For a list of these schemes, see here.

The recommended profile is '2', however I have found that this setting tends to skew other settings and so I don't recomend this as a start, but you will probably end up using it as it is very good for not accelerating short-quick movements between menu items). Use 4 or 7, to get some experience, then change to 2 afterwards.

(Apparently "4" also disables 'xset m')

Device Accel Constant Deceleration

Counters any acceleration by the given factor.
e.g 2 will halve the acceleration.

(it does so by reducing velocity estimates at device level)

This is by far the most useful option to tweak, and you should be varying with this control rather than any other setting. It has the most effect to slow down high resolution mice.

Device Accel Adaptive Deceleration
Applies the given current Acceleration-Profile to a decelerator of the given value.
e.g a linear profile will decelerate linearly. For non-linear profiles, this may help slow mouse movements to 'not speed up too fast'.

Has no effect if:
If there is no Acceleration profile (e.g Device Accel Profile = -1),
if acceleration is turned off (e.g xset m 1 0 or xinput --set-ptr-feedback <id> 0 1 1)

Has little or no effect depending on the current Acceleration-Profile. Most unpredictable. Not worth the headache. Just leave it off by setting to 1.

Device Accel Velocity Scaling

Scales the current velocity estimate and hence affects the acceleration.
VelocityScale = 1000/ExpectedRate
where ExpectedRate is the reporting frequency of your mouse (e.g 100Hz)
Default is 10 (100Hz)

To determine your mouse poll frequency, use evhz.

  Generally, the higher the frequency, the lower the value and the lower the acceleration.
        e.g 90,100,125 hz correspond to scalings 11,10,8.
        You don't have to strictly follow the calculation, i.e you can change this value to compensate
        for other settings.

 It used to be (pre-2014) on most modern mice,
125Hz corresponding to a setting of 8.
These days high resolution mice are about 200Hz correspnding to a setting of 5.

Harmony with XORG

You can infact duplicate these settings in xorg. And it will be what you end up doing once you have them setup just the way you want.

Normally, Xorg is the first to set the mouse speed at boot-up, followed by lxsession, and if you installed one, followed by your script. If you use xorg settings, then you should comment out the mouse settings in ~/.config/lxsession/Lubuntu/desktop.conf and disable your scripts.
Xorg is also the default setting after a KVM switch, so you might want to set it anyway.

Here is an example 20-evdev-mouse.conf inside /usr/share/X11/xorg.conf.d.

Section "InputClass"
    Identifier "Mouse"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"

# Set Acceleration. 1 1 0 to disable default acceleration.
    Option "AccelerationNumerator" "1"
    Option "AccelerationDenominator" "1"
    Option "AccelerationThreshold" "0"

# predictable, lightweight, none
    Option "AccelerationScheme" "predictable"

# 0 .. 7 (recommended=2, but 4 or 7 are easier to tweak)
    Option "AccelerationProfile" "4"

# 1000/ExpectedRate (default=10)
    Option "VelocityScale" "5"

#  decelerate (most important and effect for HR mice)
    Option "ConstantDeceleration" "2"

#  decelerate according to profile (most unpredictable, just turn it off)
    Option "AdaptiveDeceleration" "1"


and here is the equivalent script   (if not using xorg.conf):

# xset m <acc> <threshold>
 xset m 1/1 0
 xset q | grep acceleration
#xinput --set-ptr-feedback $ID 0 18 10    #(an alternative to xset m)


ID=`xinput list --short | grep -i $NAME | cut -f2 | cut -c4-| head -n1 `
echo $NAME Mouse ID is $ID

xinput --set-prop $ID "Device Accel Profile" 4
xinput --set-prop $ID "Device Accel Constant Deceleration" 2.0
xinput --set-prop $ID "Device Accel Adaptive Deceleration" 1
xinput --set-prop $ID "Device Accel Velocity Scaling" 5
xinput --list-props $ID | grep Accel

if [ "$1" != "fast" ]; then
 sleep 2
 sleep 0.2

And here is an example setting for profile:2
acceleration:  12/10    threshold:  75

Device Accel Profile :    2
Device Accel Constant Deceleration :    3.0
Device Accel Adaptive Deceleration :    1.0
Device Accel Velocity Scaling :    5.0

The Xorg config is the default after KVM switching, so it will be the most convenient if you use a KVM, otherwise you will have to execute a script after every KVM switch.



[ More Lubuntu Tips,  Home ]

Leading Cloud Surveillance service

Leading Enterprise Cloud IT Service Since 2003

Powered by, a division of DriveHQ, the leading Cloud IT and Cloud Surveillance Service provider since 2003.