ubuntu 18.04.2 on a Thinkpad T480

I want to run a udev script when my mouse is connected. I am happy to assume that a user called tim has a Xsession running (I use kde plasma).

objective is to configure middle button scrolling for a Logitech usb mouse including hot plugging it.

My rule is in:


ACTION=="add" \
, ATTRS{idProduct}=="c539" \
, ATTRS{idVendor}=="046d" \
, ENV{DISPLAY}=":0" \
, ENV{XAUTHORITY}="/tmp/xauth-1000-_0" \
, RUN+="/home/tim/scripts/tweak_libinput.sh"

The location of XAUTHORITY is copied from what I see in a shell.

I have a call to logger in the script, and it is getting called, multiple times (why?) So the udev rule is working, although I expected it to be called only once.

It is having some effect, because it breaks my natural scrolling settings ... that same script sets natural scrolling on, but after the udev invocation, the natural scrolling settings are reset. So it is worse than failing, it is actually breaking my settings :)

When the script is run manually, it works fine. Regardless of how many times I invoke it.


ls -l /tmp/xauth-1000-_0 
-rw------- 1 tim tim 53 Jun 11 20:07 /tmp/xauth-1000-_0

is this permission setting going to be a problem?

  • Ah. according to this it's complicated: bbs.archlinux.org/viewtopic.php?id=180079 Commented Jun 11, 2019 at 10:49
  • Use xorg.conf instead, udev is an alien. man(4) of libinput contains required info.
    – user.dz
    Commented Oct 13, 2019 at 23:33
  • The point of udev is to react to hardware changes (I come back to my desk and connect to mouse). Can't do this with x.org as far as I know. Commented Oct 13, 2019 at 23:37
  • So libinput properties you are trying to change are not for same device (attached mouse)? Could you add contents of the script?
    – user.dz
    Commented Oct 13, 2019 at 23:39
  • The mouse was not connected when the session began. Later it is connected. Commented Oct 13, 2019 at 23:40

1 Answer 1


It is possible to do this with a configuration file on /usr/share/X11/xorg.conf.d/41-libinput-local.conf

These contents work for a specific device:

Section "InputClass"
        Identifier "Logitech USB Receiver Mouse"
        MatchIsPointer "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
        Option "ScrollButton" "2"
        Option "ScrollMethod" "button"
        Option "NaturalScrolling" "true"

It works when the device is hot plugged after the session begins, and it survives during suspend/resume, as reported by Tim (OP).


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .