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?
You need env variables DISPLAY and XAUTHORITY. In X terminals they are set.
You can set it in script or in udev rule
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.