humpty > promotes Linux  > Lubuntu Tips

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

Create a Script
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 decades, Linux has 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 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.

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.


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.

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" "30"

    Option "AccelerationProfile" "0"
    Option "ConstantDeceleration" "1.2"

    Option "VelocityScale" "8"
#    Option "AdaptiveDeceleration" "1"
#    Option "AccelerationScheme" "none"
EndSection

3 . Remember to remove any libinput .conf file if you had one previously.
Here is a script for testing in evdev;
#!/bin/bash
clear
# xset m <acc> <threshold>
  xset m 2 30
  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" 0
xinput --set-prop $ID "Device Accel Constant Deceleration" 1.2

xinput --set-prop $ID "Device Accel Adaptive Deceleration" 1
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"
Acceleration Profile "AccelerationProfile" "Device Accel Profile"


To start, keep Acceleration as 2/1. It 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.

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.
Over 100 (mickeys=pixels) any wrist movement does not become noticeable. So you can use this to supress acceleration.
Below 50, you will see some affect. Recommended is 30 although you may not notice any difference until go as low as 20.

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.

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, try
"AccelerationProfile" "7"

For those that love acceleration
"AccelerationProfile" "2"

Some examples
# Almost No acceleration due to equal Deceleration + low sensistivity
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

# (This is as close to ms windows as I could get)
# Quick response for both short and long range
xset m 2 8
xinput --set-prop $ID "Device Accel Constant Deceleration" 1.8
xinput --set-prop $ID "Device Accel Profile" 7

End.

Advertisement Space

[ More Lubuntu Tips,  Home ]




Leading Cloud Surveillance, Recording and Storage service; IP camera live viewing

Leading Enterprise Cloud IT Service; cloud file server, FTP Hosting, Online Storage, Backup and Sharing

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