humpty > promotes Linux  > Lubuntu Tips

Lubuntu linux Tips
(2015-2020) 
Setting your mouse speed
This is a way to setup your mouse speed.
(updated for lubuntu 18.04)

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. (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 ~
>leafpad 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.97

xinput --list-props $ID | grep Accel

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

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.970000
    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 >
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;

~/.config/lxsession/Lubuntu/
desktop.conf

[Mouse]
#AccFactor=50
#AccThreshold=50
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 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, 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 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.

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


Section "InputClass"
  Identifier "mouse"
  MatchDriver "libinput"
#  MatchProduct "<substring of the device name>"
  MatchIsPointer "yes"

  Option "AccelSpeed" "-0.97"
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.


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.