1

This script is used to detect inserting a mouse, and disable / enable the touchpad.

this is the udev rule that triggers the script:

ENV{DEVTYPE}=="usb_device", ACTION=="add", RUN+="/usr/local/bin/enable-disable-touchpad-when-add-remove-mouse.sh"

The problem: the command synclient is not working when invoked by the udev-rule.

Funny thing, is that the script indeed runs and writes to the log when the mouse is inserted or removed (I can tail -f the log and see it runs).

The script works without a problem under any user (also root) account when I run it manually from the shell. Here's the script

#!/bin/bash
let x=`lsusb | grep -i logite | wc -l`+`lsusb | grep -i mouse | wc -l`
echo `id` >> /tmp/usblog2
if [ $x -gt 0 ]
    then 
        echo touch off >> /tmp/usblog2
        /usr/bin/synclient touchpadoff=1
    else 
        echo touch on >> /tmp/usblog2
        /usr/bin/synclient touchpadoff=0
fi

Any guesses on why synclient doesn't run under udev?

Berry Tsakala
  • 15,313
  • 12
  • 57
  • 80

1 Answers1

1

You need env variables DISPLAY and XAUTHORITY. In X terminals they are set.

You can set it in script or in udev rule

https://wiki.archlinux.org/index.php/Touchpad_Synaptics#Disable_touchpad_upon_external_mouse_detection

rofrol
  • 14,438
  • 7
  • 79
  • 77