1

I created rules which should run a command when i attach my USB mouse to disable the touchpad and the point stick:

machine ~ # cat /etc/udev/rules.d/61-touchpad.rules 
# 61-touchpad.rules
# disable PS/2 touchpad on DISPLAY :0 if a mouse is added to the system
ACTION=="add", SUBSYSTEM=="input", ENV{ID_INPUT_MOUSE}=="1", ENV{ID_BUS}=="usb", ENV{DISPLAY}=":0.0", ENV{XAUTHORITY}="/home/user/.Xauthority", RUN+="/usr/bin/xinput --disable 'AlpsPS/2 ALPS GlidePoint'"

# enable PS/2 touchpad on DISPLAY :0 if a mouse is removed from the system
ACTION=="remove", SUBSYSTEM=="input", ENV{ID_INPUT_MOUSE}=="1", ENV{ID_BUS}=="usb", ENV{DISPLAY}=":0.0", ENV{XAUTHORITY}="/home/user/.Xauthority", RUN+="/usr/bin/xinput --enable 'AlpsPS/2 ALPS GlidePoint'"

# disable Point Stick on DISPLAY :0 if a mouse is added to the system
ACTION=="add", SUBSYSTEM=="input", ENV{ID_INPUT_MOUSE}=="1", ENV{ID_BUS}=="usb", ENV{DISPLAY}=":0.0", ENV{XAUTHORITY}="/home/user/.Xauthority", RUN+="/usr/bin/xinput --disable 'DualPoint Stick'"

# enable Point Stick on DISPLAY :0 if a mouse is removed from the system
ACTION=="remove", SUBSYSTEM=="input", ENV{ID_INPUT_MOUSE}=="1", ENV{ID_BUS}=="usb", ENV{DISPLAY}=":0.0", ENV{XAUTHORITY}="/home/user/.Xauthority", RUN+="/usr/bin/xinput --enable 'DualPoint Stick'"

machine ~ #

When i run the command as root from a shell, setting DISPLAY and XAUTHORITY before, then the touch pad and point stick is activated / deactivated accordingly when i remove / re-attach the USB mouse.

When i use udevadm test --action=add /sys/class/input/mouse0 to test the rules, udev writes lots of information, amongst this it writes that it run the commands with the proper environment:

LINK 'input/by-path/pci-0000:00:14.0-usb-0:6:1.0-mouse' /lib/udev/rules.d/60-persistent-input.rules:32
RUN '/usr/bin/xinput --disable 'AlpsPS/2 ALPS GlidePoint'' /etc/udev/rules.d/61-touchpad.rules:20
RUN '/usr/bin/xinput --disable 'DualPoint Stick'' /etc/udev/rules.d/61-touchpad.rules:26
device 0x7f0315c20320 filled with db file data
...
ACTION=add
DEVLINKS=/dev/input/by-id/usb-Logitech_USB_Optical_Mouse-mouse /dev/input/by-path/pci-0000:00:14.0-usb-0:6:1.0-mouse
DEVNAME=/dev/input/mouse0
DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-6/3-6:1.0/0003:046D:C077.002A/input/input63/mouse0
DISPLAY=:0.0
ID_BUS=usb
ID_INPUT=1
ID_INPUT_MOUSE=1
ID_MODEL=USB_Optical_Mouse
...
MAJOR=13
MINOR=32
SUBSYSTEM=input
UDEV_LOG=7
USEC_INITIALIZED=8190049649
XAUTHORITY=/home/user/.Xauthority
run: '/usr/bin/xinput --disable 'AlpsPS/2 ALPS GlidePoint''
run: '/usr/bin/xinput --disable 'DualPoint Stick''
...

When i run udevd --debug and remove / re-attach the USB mouse, i get lots of information about whats going on:

starting '/usr/bin/xinput --disable 'AlpsPS/2 ALPS GlidePoint''
starting '/usr/bin/xinput --disable 'AlpsPS/2 ALPS GlidePoint''
'/usr/bin/xinput --disable 'AlpsPS/2 ALPS GlidePoint'' [27714] exit with return code 0
'/usr/bin/xinput --disable 'AlpsPS/2 ALPS GlidePoint'' [27715] exit with return code 0
starting '/usr/bin/xinput --disable 'DualPoint Stick''
starting '/usr/bin/xinput --disable 'DualPoint Stick''
'/usr/bin/xinput --disable 'DualPoint Stick'' [27719] exit with return code 0

Everything looks nice... the only issue is that the touchpad and point stick is not disabled when i attach the USB mouse.

Did i miss something?

  • the issue seem to be somewhere in the device properties "Device Enabled" vs. "Synaptics Off" vs. synclient TouchpadOff=1 – Joysn Apr 1 '16 at 18:17
  • i could not figure out why, but setting "Device Enabled" to 0 or "Synaptics Off" to 1 did not work, i could only use synclient TouchpadOff=1 to disable the touch pad. – Joysn Apr 1 '16 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.