humpty promotes > Linux > Lubuntu Tips

Lubuntu linux Tips
(2015-2022) 
Setting your mouse speed
This is a way to setup your mouse speed.

Getting Information
Create a Script
Acceleration Explained
Harmony with Xorg
Flat Acceleration
Going back to evdev

(updated for lubuntu 20.04, 22.04)

The most basic device you need for a desktop. Amazingly for multiple decades, Linux has still managed to make it difficult for users to 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 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.

For most distros, input is now handled by libinput which replaces evdev + xset. There are far fewer options, you can only set the acceleration and there are only two profiles to choose from.

Here I'll show you how to fix you mouse speed for Lubuntu.


Getting Information
xinput
This command gets information about devices;

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. (it will be different for yours).
Once you know how to get the ID, you can use it in a script..

2. Create the script
$ cd ~
$ <your_editor> fixmouse.sh

#!/bin/bash
clear

#NAME=Dakai
NAME='Wireless'

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

#input driver - libinput
xinput --set-prop $ID "libinput Accel Speed" -0.80

xinput --list-props $ID | grep Accel


The NAME='Wireless' line is the device ID. You should replace the word 'Wireless' with a word you see from xinput list --short.

The key command here is xinput --set-prop $ID "libinput Accel Speed" -0.80 which set decelerates (negative acceleration). It's value is between -1 and 1.
So e.g -0.99 will hardly move the pointer and 1 is the maximum speed.

To run it, first make it executable;
$ chmod 775 fixmouse.sh
Then run it
$ ./fixmouse.sh

  Example output :
Wireless Mouse ID is 11
    libinput Accel Speed (283):    -0.800000
    libinput Accel Speed Default (284):    0.000000
    libinput Accel Profiles Available (285):    1, 1
    libinput Accel Profile Enabled (286):    1, 0
    libinput Accel Profile Enabled Default (287):    1, 0


3. If you want to run this script every time you login, then see, < lubuntu-autostart >

Your session manager might still override both xorg and your autostart script. If this is the case, then to disable lxsession effects, comment out these lines in;

~/.config/lxsession/Lubuntu/
desktop.conf
(for LXQt, the settings are inside ~/.config/lxqt/session.conf and they will be different)

[Mouse]
#AccFactor=50                      ** Make sure these
#AccThreshold=50                ** lines are commented out
LeftHanded=0

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

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


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


Acceleration Explained

The common approach with mouse control schemes is to first set an Acceleration and then to Tame it.

Without acceleration, the pointer will not move very far for a fling of the wrist.
This is especially true for low dpi (800) mice.
He higher the dpi, the more pixel distance is reported for the same wrist movement.
So for low dpi, you need more Acceleration, and for hight dpi, you need less.

To start, you will want at least some acceleration to work with. 2/1 seems to be a common standard.
By keeping this as 2, it will be easier to tweak the other options until you are familiar with them.


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/lxqt, followed by your scripts. If you use xorg settings, then you should disable your scripts and comment out the mouse settings in ~/.config/lxsession/Lubuntu/desktop.conf or ~/.config/lxqt/session.conf.

Xorg is also the default setting after any KVM switch, (i.e when you toggle between two PCs with the same keyboard) so you might want to do this if you are using a KVM.

To get Xorg to load your settings at boot, create an Xorg conf file (if one does not already exist) inside
/usr/share/X11/xorg.conf.d/
e.g
/usr/share/X11/xorg.conf.d/45-mouse.conf

Section "InputClass"
  Identifier "mouse"
  MatchDriver "libinput"
  MatchIsPointer "yes"

  Option "AccelSpeed" "-0.80"
EndSection

To activate, logout and log back in.

Notes:
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.


Flat Acceleration

This is an alternative technique to slow down your mouse using the Xorg conf file.
If you still feel the mouse moves or feels weird, even though you have slowed it down with AccelSpeed, then you can opt to have a 'flat' acceleration profile (the default is 'adaptive').
e.g
/usr/share/X11/xorg.conf.d/45-mouse.conf

Section "InputClass"
  Identifier "mouse"
  MatchDriver "libinput"
  MatchIsPointer "yes"

  Option "AccelSpeed" "-0.3"
  Option "AccelProfile" "flat"
EndSection

A flat profile, requires less deceleration (negative AccelSpeed) and is the closest thing you can get to 'constant' speed. In this case AccelSpeed behaves more like speed than acceleration.


Going Back to evdev

Still not satisfied ? You can always go back to evdev, it offers a lot more options.
To use evdev, you must turn off any libinput settings.
1. Install the evdev input for xorg
apt-get install xserver-xorg-input-evdev

2. Create an xorg  .conf file
/usr/share/X11/xorg.cong.d/50-evdev-mouse.conf
Section "InputClass"
    Identifier "Mouse"
    MatchIsPointer "yes"
    Driver "evdev"

    Option "AccelerationNumerator" "2"
    Option "AccelerationDenominator" "1"
    Option "AccelerationThreshold" "100"

    Option "AccelerationProfile" "7"
    Option "ConstantDeceleration" "1.5"
    Option "AdaptiveDeceleration" "1.5"
 
    Option "VelocityScale" "8"
#    Option "AccelerationScheme" "none"
EndSection

3 . Remember to remove any libinput .conf file if you had one previously.
Here is a script for testing evdev with xset and xinput commands. The settings are only temporary until a reboot.
#!/bin/bash
clear
# xset m <acc> <threshold>
  xset m 2 100
  xset q | grep acceleration
#xinput --set-ptr-feedback $ID 0 18 10    #(an alternative to xset m)

NAME='Mouse'

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" 7
xinput --set-prop $ID "Device Accel Constant Deceleration" 1.5
xinput --set-prop $ID "Device Accel Adaptive Deceleration" 1.5
xinput --set-prop $ID "Device Accel Velocity Scaling" 8

xinput list-props $ID | grep Accel
There are 4 settings that are most useful.


Xorg Conf
xset or xinput
Acceleration "AccelerationNumerator"
"AccelerationDenominator"
xset m <acceleration>
Threshold "AccelerationThreshold" xset m <acceleration> <threshold>
Constant Deceleration "ConstantDeceleration" "Device Accel Constant Deceleration"
Adaptive Deceleration "AdaptiveDeceleration" "Device Accel Adaptive Deceleration"
Acceleration Profile "AccelerationProfile" "Device Accel Profile"

Acceleration. Without Acceleration, the pointer will not move very far for a fling of the wrist.
It seems the common standard is 2. The equivalent command is xset m 2
It is not recommended to set an Acceleration without a Threshold. e.g use xset m 2 100
otherwise the acceleration will be untamed and wild.

If you have an old mouse fixed at a low dpi (e.g 800,dpi), and short movement does not go very far, you may have no other option but to increase the Acceleration to 3 or 4.
Acceleration for evdev uses whole numbers as fractions instead of floating point expressed as
AccelerationNumerator
-----------------------
AccelerationDenominator

Threshold controls the sensitivity. The difference is how hard you have to fling your wrist in order to get the pointer to a corner of the screen. A low threshold will get you there quicker.
A setting of over 100 (mickeys=pixels) makes any wrist movement becomes less noticeable. Increase this to suppress acceleration.
Below 50, you will see significant affects of higher speed. Recommended is to keep it at 100 to suppress adverse effects, then tweak it later.

Constant Deceleration acts against acceleration and is the most significant setting, even though it does not act 'directly' against it one-to-one. To tame aggressive profiles such as 2, you will need to tweak this setting quite a lot.

examples are  1.0 for 800 dpi. 1.5 for 1200dpi and 2 for 1600dpi.
When the mouse is running at a high dpi setting (e.g 1600), there are more pixels reported per movement. Therefore you need more Deceleration for control.

The mininum setting is 1.0

Adaptive Deceleration adds to constant deceleration for short distances.
This makes short distances less affective and long distances more responsive.
So editing becomes manageable while a flick of the wrist will get to a far away menu quickly.
You should set this to 1.0 to start off and then tweak it later.
The mininum setting is 1.0

It is possible to turn off Constant Deceleration and set only Adaptive deceleration (e.g Logitech).

Profiles
For users who like a quiet life with no thrills or need precise movement over a small area,
"AccelerationProfile" "0" gives the minimum of acceleration, which is close to flat acceleration.
Do note that if you need to get to the far corner of the screen, you may have to drag your mouse several times to get there.

For users who want some acceleration but needs to keep a lid on large movements, I recommend
"AccelerationProfile" "7"

For those that love acceleration
"AccelerationProfile" "2"

Some examples
# Almost No acceleration due to equal Deceleration + low sensistivity for 800dpi
xset m 2 100
xinput --set-prop $ID "Device Accel Constant Deceleration" 2.0
xinput --set-prop $ID "Device Accel Profile" 0

# Conservative - low acceleration + medium sensitivity
xset m 2 30
xinput --set-prop $ID "Device Accel Constant Deceleration" 1.8
xinput --set-prop $ID "Device Accel Profile" 0

# Regular - meduim flat acceleration + low sensitivity for menus
xset m 2 80
xinput --set-prop $ID "Device Accel Constant Deceleration" 1.5
xinput --set-prop $ID "Device Accel Profile" 0
xinput --set-prop $ID "Device Accel Profile" 7

# Accomdative - fast for long range, subdued short range
# (This is as close to ms windows as I could get)

xset m 2 80
xinput --set-prop $ID "Device Accel Constant Deceleration" 1.6
xinput --set-prop $ID "Device Accel Adaptive Deceleration" 1.2
xinput --set-prop $ID "Device Accel Profile" 7

# An example of using only Adaptive'. (for a Logitech mouse at 1200 dpi)
xset m 2 100
xinput --set-prop $ID "Device Accel Constant Deceleration" 1.0
xinput --set-prop $ID "Device Accel Adaptive Deceleration" 1.5
xinput --set-prop $ID "Device Accel Profile" 7


# For an old mouse fixed at 800 dpi. Needs more acceleration & response.
xset m 25/10 80
xinput --set-prop $ID "Device Accel Constant Deceleration" 1.0
xinput --set-prop $ID "Device Accel Adaptive Deceleration" 1.0
xinput --set-prop $ID "Device Accel Profile" 7
xinput --set-prop $ID "Device Accel Velocity Scaling" 8
End.

Advertisement Space

[ More Lubuntu Tips,  Home ]