I'm trying to write a udev rule to disable (and re-enable) my trackpad when a USB mouse is connected.

Currently, my rule looks like:

ACTION=="add", ATTRS{bInterfaceProtocol}=="02", ATTRS{bInterfaceClass}=="03", ATTRS{bInterfaceSubClass}=="01", ENV{REMOVE_CMD}="/usr/bin/synclient TouchpadOff=0", RUN+="/usr/bin/synclient TouchpadOff=1"

and I've saved this in /etc/udev/rules.d/99-mouse-touchpad.rules and reloaded using udevadm control --reload but nothing happens when I plug/unplug my mouse at all.

1 Answer 1


I think, you should use sudo your_user for the utility, or pass DISPLAY environmant variable, so it could communicate with Xorg driver. And, make sure you have synaptics driver active...

Try running synclient as root with cleared environment (simulate run by udev) - i'm guessing, it won't do anything.

  • This worked, thanks! I just had to pass the ENV{XAUTHORITY} and ENV{DISPLAY} arguments and it works perfectly now :D
    – Basil
    Sep 21, 2022 at 15:02

You must log in to answer this question.

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