You are not logged in.
Hello guys,
I tried the udev-rule from the wiki to disable/enable touchpad when my usbmouse is plugged/unplugged.
Here is the rule:
#/etc/udev/rules.d/01-touchpad.rules  
ACTION=="add", SUBSYSTEM=="input", ENV{ID_CLASS}="mouse", RUN+="/usr/bin/synclient TouchpadOff=1"
ACTION=="remove", SUBSYSTEM=="input", ENV{ID_CLASS}="mouse", RUN+="/usr/bin/synclient TouchpadOff=0"The problem is that the status of my touchpad won't change when I plug/unplug my mouse. It has to be a problem with the rule because manually the synclient command works without any problem.
Here is the relevant output of lsusb:
Bus 007 Device 012: ID 046d:c00c Logitech, Inc. Optical Wheel MouseThank you. ![]()
Last edited by orschiro (2010-03-18 15:15:10)
Offline
I _know_ its not what you are looking for - but here's another way ...
"rmmod psmouse" in /etc/rc.local (seeing that I almost always use a usb-mouse)
If I dont have a mouse, "modprobe psmouse" on the command line (I always boot up to the cli - then startx) - thus I always have some kind of pointing device available by the time X comes up
I must admit I don't like playing around with 'rules' - rmmod/modprobe works fine for me.
Offline
SUBSYSTEMS=="usb", DRIVERS=="usb", ATTRS{manufacturer}=="Logitech", ATTRS{product}=="USB Receiver", ACTION=="add", RUN+="/usr/bin/touchpadtoggle 1"
SUBSYSTEMS=="usb", DRIVERS=="usb", ATTRS{manufacturer}=="Logitech", ATTRS{product}=="USB Receiver", ACTION=="remove", RUN+="/usr/bin/touchpadtoggle 0"where touchpadtoggle is
#!/bin/bash
export DISPLAY=":0"
/usr/bin/synclient touchpadoff=$1Offline
Might not be really what you're looking for (but I'll post it anyway). Thunar and thunar-volman can be setup to run a program/script when a mouse is inserted. Give it a try!
Offline
show result of
ls -l /usr/bin/touchpadtoggleand just to be sure. You've modified that udev-rule to fit your mouse, havent you?
[root@thinkpad]# ls -l /usr/bin/touchpadtoggle
-rwxr-xr-x 1 root root 66 11. Mär 13:31 /usr/bin/touchpadtoggleYeah I adapted it the following:
SUBSYSTEMS=="usb", DRIVERS=="usb", ATTRS{manufacturer}=="Logitech", ATTRS{product}=="Inc. Optical Wheel Mouse", ACTION=="add", RUN+="/usr/bin/touchpadtoggle 1"
SUBSYSTEMS=="usb", DRIVERS=="usb", ATTRS{manufacturer}=="Logitech", ATTRS{product}=="Inc. Optical Wheel Mouse", ACTION=="remove", RUN+="/usr/bin/touchpadtoggle 0"I think it should be right?
Last edited by orschiro (2010-03-12 16:38:38)
Offline
Well, seems that script is executable and runs fine, as you said, so the only option is some mistakes in udev-rules.
Try running 
udevadm monitor --property > ./logand plug in or out your mouse.
Then open ./log file, you'll see a bunch of events there. Your udev-rule will work if it satisfies any of this. So choose one and modify your rule to fit it
Last edited by Coacher (2010-03-12 21:53:36)
Hello Coacher,
I did what you said but have no idea what to do with that logfile. I'll better post it here. Perhaps you could help me again.
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
KERNEL[1268568009.445312] remove   /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input14/mouse2 (input)
UDEV_LOG=0
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input14/mouse2
SUBSYSTEM=input
DEVNAME=input/mouse2
SEQNUM=48167
MAJOR=13
MINOR=34
KERNEL[1268568009.461185] remove   /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input14/event14 (input)
UDEV_LOG=0
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input14/event14
SUBSYSTEM=input
DEVNAME=input/event14
SEQNUM=48168
MAJOR=13
MINOR=78
KERNEL[1268568009.471273] remove   /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input14 (input)
UDEV_LOG=0
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input14
SUBSYSTEM=input
PRODUCT=3/46d/c00c/110
NAME="Logitech USB Mouse"
PHYS="usb-0000:00:1d.1-2/input0"
UNIQ=""
EV==17
KEY==70000 0 0 0 0
REL==103
MSC==10
MODALIAS=input:b0003v046DpC00Ce0110-e0,1,2,4,k110,111,112,r0,1,8,am4,lsfw
SEQNUM=48169
KERNEL[1268568009.471331] remove   /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/0003:046D:C00C.0001/hidraw/hidraw0 (hidraw)
UDEV_LOG=0
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/0003:046D:C00C.0001/hidraw/hidraw0
SUBSYSTEM=hidraw
DEVNAME=hidraw0
SEQNUM=48170
MAJOR=251
MINOR=0
KERNEL[1268568009.472063] remove   /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/0003:046D:C00C.0001 (hid)
UDEV_LOG=0
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/0003:046D:C00C.0001
SUBSYSTEM=hid
HID_ID=0003:0000046D:0000C00C
HID_NAME=Logitech USB Mouse
HID_PHYS=usb-0000:00:1d.1-2/input0
MODALIAS=hid:b0003v0000046Dp0000C00C
SEQNUM=48171
KERNEL[1268568009.472116] remove   /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0 (usb)
UDEV_LOG=0
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0
SUBSYSTEM=usb
DEVTYPE=usb_interface
DEVICE=/proc/bus/usb/007/002
PRODUCT=46d/c00c/610
TYPE=0/0/0
INTERFACE=3/1/2
MODALIAS=usb:v046DpC00Cd0610dc00dsc00dp00ic03isc01ip02
SEQNUM=48172
KERNEL[1268568009.473105] remove   /devices/pci0000:00/0000:00:1d.1/usb7/7-2 (usb)
UDEV_LOG=0
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2
SUBSYSTEM=usb
DEVNAME=bus/usb/007/002
DEVTYPE=usb_device
DEVICE=/proc/bus/usb/007/002
PRODUCT=46d/c00c/610
TYPE=0/0/0
BUSNUM=007
DEVNUM=002
SEQNUM=48173
MAJOR=189
MINOR=769
UDEV  [1268568009.596460] remove   /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input14/event14 (input)
UDEV_LOG=0
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input14/event14
SUBSYSTEM=input
DEVNAME=/dev/input/event14
SEQNUM=48168
ID_INPUT=1
ID_INPUT_MOUSE=1
ID_VENDOR=Logitech
ID_VENDOR_ENC=Logitech
ID_VENDOR_ID=046d
ID_MODEL=USB_Mouse
ID_MODEL_ENC=USB\x20Mouse
ID_MODEL_ID=c00c
ID_REVISION=0610
ID_SERIAL=Logitech_USB_Mouse
ID_TYPE=hid
ID_BUS=usb
ID_USB_INTERFACES=:030102:
ID_USB_INTERFACE_NUM=00
ID_USB_DRIVER=usbhid
ID_PATH=pci-0000:00:1d.1-usb-0:2:1.0
MAJOR=13
MINOR=78
DEVLINKS=/dev/char/13:78 /dev/input/by-id/usb-Logitech_USB_Mouse-event-mouse /dev/input/by-path/pci-0000:00:1d.1-usb-0:2:1.0-event-mouse
UDEV  [1268568009.605422] remove   /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/0003:046D:C00C.0001/hidraw/hidraw0 (hidraw)
UDEV_LOG=0
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/0003:046D:C00C.0001/hidraw/hidraw0
SUBSYSTEM=hidraw
DEVNAME=/dev/hidraw0
SEQNUM=48170
MAJOR=251
MINOR=0
DEVLINKS=/dev/char/251:0
UDEV  [1268568009.606695] remove   /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input14/mouse2 (input)
UDEV_LOG=0
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input14/mouse2
SUBSYSTEM=input
DEVNAME=/dev/input/mouse2
SEQNUM=48167
ID_INPUT=1
ID_INPUT_MOUSE=1
ID_VENDOR=Logitech
ID_VENDOR_ENC=Logitech
ID_VENDOR_ID=046d
ID_MODEL=USB_Mouse
ID_MODEL_ENC=USB\x20Mouse
ID_MODEL_ID=c00c
ID_REVISION=0610
ID_SERIAL=Logitech_USB_Mouse
ID_TYPE=hid
ID_BUS=usb
ID_USB_INTERFACES=:030102:
ID_USB_INTERFACE_NUM=00
ID_USB_DRIVER=usbhid
ID_PATH=pci-0000:00:1d.1-usb-0:2:1.0
MAJOR=13
MINOR=34
DEVLINKS=/dev/char/13:34 /dev/input/by-id/usb-Logitech_USB_Mouse-mouse /dev/input/by-path/pci-0000:00:1d.1-usb-0:2:1.0-mouse
UDEV  [1268568009.608264] remove   /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/0003:046D:C00C.0001 (hid)
UDEV_LOG=0
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/0003:046D:C00C.0001
SUBSYSTEM=hid
HID_ID=0003:0000046D:0000C00C
HID_NAME=Logitech USB Mouse
HID_PHYS=usb-0000:00:1d.1-2/input0
MODALIAS=hid:b0003v0000046Dp0000C00C
SEQNUM=48171
UDEV  [1268568009.609657] remove   /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input14 (input)
UDEV_LOG=0
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input14
SUBSYSTEM=input
PRODUCT=3/46d/c00c/110
NAME="Logitech USB Mouse"
PHYS="usb-0000:00:1d.1-2/input0"
UNIQ=""
EV==17
KEY==70000 0 0 0 0
REL==103
MSC==10
MODALIAS=input:b0003v046DpC00Ce0110-e0,1,2,4,k110,111,112,r0,1,8,am4,lsfw
SEQNUM=48169
UDEV  [1268568009.611650] remove   /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0 (usb)
UDEV_LOG=0
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0
SUBSYSTEM=usb
DEVTYPE=usb_interface
DEVICE=/proc/bus/usb/007/002
PRODUCT=46d/c00c/610
TYPE=0/0/0
INTERFACE=3/1/2
MODALIAS=usb:v046DpC00Cd0610dc00dsc00dp00ic03isc01ip02
SEQNUM=48172
UDEV  [1268568009.614119] remove   /devices/pci0000:00/0000:00:1d.1/usb7/7-2 (usb)
UDEV_LOG=0
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2
SUBSYSTEM=usb
DEVNAME=/dev/bus/usb/007/002
DEVTYPE=usb_device
DEVICE=/proc/bus/usb/007/002
PRODUCT=46d/c00c/610
TYPE=0/0/0
BUSNUM=007
DEVNUM=002
SEQNUM=48173
ID_VENDOR=Logitech
ID_VENDOR_ENC=Logitech
ID_VENDOR_ID=046d
ID_MODEL=USB_Mouse
ID_MODEL_ENC=USB\x20Mouse
ID_MODEL_ID=c00c
ID_REVISION=0610
ID_SERIAL=Logitech_USB_Mouse
ID_BUS=usb
ID_USB_INTERFACES=:030102:
MAJOR=189
MINOR=769
DEVLINKS=/dev/char/189:769
KERNEL[1268568012.396622] add      /devices/pci0000:00/0000:00:1d.1/usb7/7-2 (usb)
UDEV_LOG=0
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2
SUBSYSTEM=usb
DEVNAME=bus/usb/007/003
DEVTYPE=usb_device
DEVICE=/proc/bus/usb/007/003
PRODUCT=46d/c00c/610
TYPE=0/0/0
BUSNUM=007
DEVNUM=003
SEQNUM=48174
MAJOR=189
MINOR=770
KERNEL[1268568012.399460] add      /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0 (usb)
UDEV_LOG=0
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0
SUBSYSTEM=usb
DEVTYPE=usb_interface
DEVICE=/proc/bus/usb/007/003
PRODUCT=46d/c00c/610
TYPE=0/0/0
INTERFACE=3/1/2
MODALIAS=usb:v046DpC00Cd0610dc00dsc00dp00ic03isc01ip02
SEQNUM=48175
KERNEL[1268568012.399649] add      /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/0003:046D:C00C.0002 (hid)
UDEV_LOG=0
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/0003:046D:C00C.0002
SUBSYSTEM=hid
HID_ID=0003:0000046D:0000C00C
HID_NAME=Logitech USB Mouse
HID_PHYS=usb-0000:00:1d.1-2/input0
DRIVER=generic-usb
MODALIAS=hid:b0003v0000046Dp0000C00C
SEQNUM=48176
KERNEL[1268568012.415310] add      /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input16 (input)
UDEV_LOG=0
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input16
SUBSYSTEM=input
PRODUCT=3/46d/c00c/110
NAME="Logitech USB Mouse"
PHYS="usb-0000:00:1d.1-2/input0"
UNIQ=""
EV==17
KEY==70000 0 0 0 0
REL==103
MSC==10
MODALIAS=input:b0003v046DpC00Ce0110-e0,1,2,4,k110,111,112,r0,1,8,am4,lsfw
SEQNUM=48177
KERNEL[1268568012.415530] add      /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input16/mouse2 (input)
UDEV_LOG=0
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input16/mouse2
SUBSYSTEM=input
DEVNAME=input/mouse2
SEQNUM=48178
MAJOR=13
MINOR=34
KERNEL[1268568012.415645] add      /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input16/event14 (input)
UDEV_LOG=0
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input16/event14
SUBSYSTEM=input
DEVNAME=input/event14
SEQNUM=48179
MAJOR=13
MINOR=78
KERNEL[1268568012.415763] add      /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/0003:046D:C00C.0002/hidraw/hidraw0 (hidraw)
UDEV_LOG=0
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/0003:046D:C00C.0002/hidraw/hidraw0
SUBSYSTEM=hidraw
DEVNAME=hidraw0
SEQNUM=48180
MAJOR=251
MINOR=0
UDEV  [1268568012.419223] add      /devices/pci0000:00/0000:00:1d.1/usb7/7-2 (usb)
UDEV_LOG=0
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2
SUBSYSTEM=usb
DEVNAME=/dev/bus/usb/007/003
DEVTYPE=usb_device
DEVICE=/proc/bus/usb/007/003
PRODUCT=46d/c00c/610
TYPE=0/0/0
BUSNUM=007
DEVNUM=003
SEQNUM=48174
ID_VENDOR=Logitech
ID_VENDOR_ENC=Logitech
ID_VENDOR_ID=046d
ID_MODEL=USB_Mouse
ID_MODEL_ENC=USB\x20Mouse
ID_MODEL_ID=c00c
ID_REVISION=0610
ID_SERIAL=Logitech_USB_Mouse
ID_BUS=usb
ID_USB_INTERFACES=:030102:
MAJOR=189
MINOR=770
DEVLINKS=/dev/char/189:770
UDEV  [1268568012.420120] add      /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0 (usb)
UDEV_LOG=0
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0
SUBSYSTEM=usb
DEVTYPE=usb_interface
DEVICE=/proc/bus/usb/007/003
PRODUCT=46d/c00c/610
TYPE=0/0/0
INTERFACE=3/1/2
MODALIAS=usb:v046DpC00Cd0610dc00dsc00dp00ic03isc01ip02
SEQNUM=48175
UDEV  [1268568012.420621] add      /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/0003:046D:C00C.0002 (hid)
UDEV_LOG=0
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/0003:046D:C00C.0002
SUBSYSTEM=hid
HID_ID=0003:0000046D:0000C00C
HID_NAME=Logitech USB Mouse
HID_PHYS=usb-0000:00:1d.1-2/input0
DRIVER=generic-usb
MODALIAS=hid:b0003v0000046Dp0000C00C
SEQNUM=48176
UDEV  [1268568012.421369] add      /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/0003:046D:C00C.0002/hidraw/hidraw0 (hidraw)
UDEV_LOG=0
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/0003:046D:C00C.0002/hidraw/hidraw0
SUBSYSTEM=hidraw
DEVNAME=/dev/hidraw0
SEQNUM=48180
MAJOR=251
MINOR=0
DEVLINKS=/dev/char/251:0
UDEV  [1268568012.453075] add      /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input16 (input)
UDEV_LOG=0
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input16
SUBSYSTEM=input
PRODUCT=3/46d/c00c/110
NAME="Logitech USB Mouse"
PHYS="usb-0000:00:1d.1-2/input0"
UNIQ=""
EV==17
KEY==70000 0 0 0 0
REL==103
MSC==10
MODALIAS=input:b0003v046DpC00Ce0110-e0,1,2,4,k110,111,112,r0,1,8,am4,lsfw
SEQNUM=48177
UDEV  [1268568012.457340] add      /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input16/mouse2 (input)
UDEV_LOG=0
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input16/mouse2
SUBSYSTEM=input
DEVNAME=/dev/input/mouse2
SEQNUM=48178
ID_INPUT=1
ID_INPUT_MOUSE=1
ID_VENDOR=Logitech
ID_VENDOR_ENC=Logitech
ID_VENDOR_ID=046d
ID_MODEL=USB_Mouse
ID_MODEL_ENC=USB\x20Mouse
ID_MODEL_ID=c00c
ID_REVISION=0610
ID_SERIAL=Logitech_USB_Mouse
ID_TYPE=hid
ID_BUS=usb
ID_USB_INTERFACES=:030102:
ID_USB_INTERFACE_NUM=00
ID_USB_DRIVER=usbhid
ID_PATH=pci-0000:00:1d.1-usb-0:2:1.0
MAJOR=13
MINOR=34
DEVLINKS=/dev/char/13:34 /dev/input/by-id/usb-Logitech_USB_Mouse-mouse /dev/input/by-path/pci-0000:00:1d.1-usb-0:2:1.0-mouse
UDEV  [1268568012.457383] add      /devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input16/event14 (input)
UDEV_LOG=0
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb7/7-2/7-2:1.0/input/input16/event14
SUBSYSTEM=input
DEVNAME=/dev/input/event14
SEQNUM=48179
ID_INPUT=1
ID_INPUT_MOUSE=1
ID_VENDOR=Logitech
ID_VENDOR_ENC=Logitech
ID_VENDOR_ID=046d
ID_MODEL=USB_Mouse
ID_MODEL_ENC=USB\x20Mouse
ID_MODEL_ID=c00c
ID_REVISION=0610
ID_SERIAL=Logitech_USB_Mouse
ID_TYPE=hid
ID_BUS=usb
ID_USB_INTERFACES=:030102:
ID_USB_INTERFACE_NUM=00
ID_USB_DRIVER=usbhid
ID_PATH=pci-0000:00:1d.1-usb-0:2:1.0
MAJOR=13
MINOR=78
DEVLINKS=/dev/char/13:78 /dev/input/by-id/usb-Logitech_USB_Mouse-event-mouse /dev/input/by-path/pci-0000:00:1d.1-usb-0:2:1.0-event-mouseThank you.
Offline
I have something fairly similar set up (which also involved a fair amount of trouble to get working). Maybe it will help.
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="<insert vendor id>", ATTRS{idProduct}=="<insert product id>", ENV{REMOVE_CMD}="/usr/bin/touchpadtoggle 0", RUN+="/usr/bin/touchpadtoggle 1"I've modified it to suit your case. I use the product and vendor IDs of the device to identify it, though you should be able to use whichever attributes you please.
Offline
I don't know what's wrong with it...
Here my updated rule:
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0x046d Logitech, Inc.", ATTRS{idProduct}=="0xc00c Optical Wheel Mouse", ENV{REMOVE_CMD}="/usr/bin/touchpadtoggle 0", RUN+="/usr/bin/touchpadtoggle 1"And this is the detailed output of lsusb -v:
Bus 007 Device 002: ID 046d:c00c Logitech, Inc. Optical Wheel Mouse
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0         8
  idVendor           0x046d Logitech, Inc.
  idProduct          0xc00c Optical Wheel Mouse
  bcdDevice            6.10
  iManufacturer           1 Logitech
  iProduct                2 USB Mouse
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           34
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      2 Mouse
      iInterface              0
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      68
         Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10
Device Status:     0x0000
  (Bus Powered)Any mistake I did?
Offline
The vendor and product IDs should be 4 digit hex -- I don't think any other value is valid. Otherwise, that looks fine.
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c00c", ENV{REMOVE_CMD}="/usr/bin/touchpadtoggle 0", RUN+="/usr/bin/touchpadtoggle 1"Offline
chpln you're great. It works flawlessly now. ![]()
Thank you man!
And just to know it, what's the sense of creating this touchpadtoggle script as I can directly use /usr/bin/synclient?
EDIT:
Just tested it without the script and it isn't working anymore. So the export DISPLAY=":0" from script seems to be necessary. But what is it for?
And is it normal that I get a error message during boot called "can not open display"?
Last edited by orschiro (2010-03-15 12:28:35)
Offline
And just to know it, what's the sense of creating this touchpadtoggle script as I can directly use /usr/bin/synclient?
EDIT:
Just tested it without the script and it isn't working anymore. So the export DISPLAY=":0" from script seems to be necessary. But what is it for?
And is it normal that I get a error message during boot called "can not open display"?
Good that you handled with udev rule.
It is not work because the synclient can and do selective touchpad on/off in multiple instances of X.
When you run it from X terminal emulator it knows that it should toogle touchpad only for current server because of DISPLAY variable is set.
When running this script via udev which runs with root user environment there is no X running there, so DISPLAY variable is not set(until you run X from root). That's why exporting it needed. 
And talking about boot message as you should understand by now, there is no X running at all on DISPLAY=0: or somewhere else, so synclient's connection to it fails. 
P.S. there could be add some workaround like this
#!/bin/bash
if [ "$(pidof X)" ]; then
export DISPLAY=":0"
/usr/bin/synclient touchpadoff=$1
fi.please note it is very stupid solution which toggles touchpad on DISPLAY 0: even if no X presented there
Last edited by Coacher (2010-03-15 19:38:14)
please note it is very stupid solution which toggles touchpad on DISPLAY 0: even if no X presented there
well here is working but REALLY ugly script which turns off touchpad for all running X servers. Its midnight here and I couldnt produce anything smarter till morning. 
P.S. very bad script, but works)
#!/bin/bash
totalX=`pidof X | xargs ps p | grep X | awk '{print $6}' | wc -l`
Xwithnum=`pidof X | xargs ps p | grep X | awk '{print $6}' | grep [0-9] | wc -l`
str=`pidof X | xargs ps p | grep X | awk '{print $6}' | grep [0-9]`
diff=`expr $totalX - $Xwithnum`
if [ "$diff" = "1" ]; then
    #echo "toggling on 0"
    export DISPLAY=":0"
    /usr/bin/synclient touchpadoff=$1
fi
while [ $Xwithnum -gt 0 ]
do
    #echo "toggling on $Xwithnum"
    Xwithnum=`expr $Xwithnum + 1`
    disp=`echo $str | cut -d':' -f$Xwithnum`
    Xwithnum=`expr $Xwithnum - 1`
    export DISPLAY=":$disp"
    /usr/bin/synclient touchpadoff=$1
    Xwithnum=`expr $Xwithnum - 1`
doneLast edited by Coacher (2010-03-15 21:03:17)
Hello Coacher,
thanks for your scripts. I tried the last one but the udev rule still doesn't work at boot.
Is there any way to change the script that the rule will work directly after startup instead of first plugging in the mouse again?
Offline
Hi. Here is script that working on my machine, but it wasnt tested during boot. So, try it and let me know if it works. 
P.S. delete all lines with 'echo' for silent-mode without any messages
#!/bin/bash
# Script to toggle on/off touchpad on all local running X-servers at the same time
# Not tested for network usage
if [ -f /var/run/touchpadtoggle.pid ]
then
    echo "Already have another task..."
    if [ `cat /var/run/touchpadtoggle.task` = "$1" ]
    then 
        echo "Already have same task. Exiting."
        exit
    else
        echo "Already have opposite task. Killing it and exiting." 
        cat /var/run/touchpadtoggle.pid | xargs kill -15
        rm /var/run/touchpadtoggle.task
        rm /var/run/touchpadtoggle.pid
        exit
    fi      
fi
toggling() {
echo "Checking for running X servers..."
if [ `pidof X | tr " " "\n" | wc -l` != "0" ]
then 
    echo "Have running X servers."
    save=$DISPLAY
    totalX=`pidof X | tr " " "\n" | wc -l`
    Xwithnum=`pidof X | xargs ps p | grep X | awk '{print $6}' | grep [0-9] | wc -l`
    dispNums=`pidof X | xargs ps p | grep X | awk '{print $7}' | grep [0-9]`
    diff=`expr $totalX - $Xwithnum`
    if [ "$diff" = "1" ]
    then
        echo "Toggling on :0"
        #export DISPLAY=":0"
        #/usr/bin/synclient touchpadoff=$1
    fi
    Xwithnum=`expr $Xwithnum + 1`
    while [ $Xwithnum -gt 1 ]
    do
        disp=`echo $dispNums | cut -d':' -f$Xwithnum`
        echo "Toggling on :$disp"
        export DISPLAY=":$disp"
        /usr/bin/synclient touchpadoff=$1
        Xwithnum=`expr $Xwithnum - 1`
    done
    export DISPLAY="$save"
    if [ -f /var/run/touchpadtoggle.pid ]
    then 
        rm /var/run/touchpadtoggle.pid
    fi
    if [ -f /var/run/touchpadtoggle.task ]
    then 
        rm /var/run/touchpadtoggle.task
    fi
else
    echo "No running X servers. Saving task and scheduling repeat after 3 seconds"
    echo "$1" > /var/run/touchpadtoggle.task
    echo "$$" > /var/run/touchpadtoggle.pid
    sleep 3
    toggling $1
    exit
fi
}
toggling $1Last edited by Coacher (2010-03-17 04:43:10)
Hello Coacher,
something isn't really working. It hangs up on boot at
Waiting for Udev uevents to be proceededI am then just able to quit it via Ctrl+C. Otherwise he would not continue.
Offline
Hm. The problem is that I dont have such problems on boot even with old version of script and cant test it.
Ah! I guess I understood where is the problem!
I'll add fix today evening:)
Last edited by Coacher (2010-03-17 04:44:04)
Haha. Shame to me. I forgot how I fixed similar problem myself. Just adding
if /usr/sbin/lsusb --verbose 2>&1 | grep --quiet "Mouse"; then
        /usr/bin/synclient TouchPadOff="1"
fito .xinitrc just before line 'exec yourDEname'
And when run you srever with startx everything should work. However, I'll try to finish working on this script.
This addition to .xinitrc will only turn on/off touchpad on X start, though you still need that touchpad toggle scipt which will handle mouse plugin/out the rest of the time.
Yeah it's working like a charme. ![]()
The only thing that still occurs is the cannot open display "" message while starting crond at boot. Any suggestion how I could deactivate that?
Perhaps with a simple > /dev/null?
Offline
Yes. Something like this
/usr/bin/synclient touchpadoff=$1 2>/dev/null