You are not logged in.

#1 2023-06-15 16:08:35

Kritiqual
Member
Registered: 2021-09-10
Posts: 21

Help writing udev rules to disable touchpad when plugging in usb mouse

I have this udev rule:

# Disable Touchpad while USB mouse is present and Enable it when USB mouse is not

ACTION=="add", ATTRS{idVendor}=="1532", ATTRS{idProduct}=="006e", \
ENV{XAUTHORITY}="/home/kritiqual/.lyxauth", ENV{DISPLAY}=":0", \
ENV{REMOVE_CMD}="/usr/bin/xinput enable 'DELL097B:00 04F3:30C3 Touchpad'", \
RUN+="/usr/bin/xinput disable 'DELL097B:00 04F3:30C3 Touchpad'"

This works fine if I test on a normal environment. But, if I restart my computer, and the usb mouse remain plugged in, then the mouse cannot be used and not being recognized by the system (not showing in

xinput list

for example)

Offline

#2 2023-06-15 20:41:55

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,329

Re: Help writing udev rules to disable touchpad when plugging in usb mouse

There's no X11 server during the boot and the run command will fail.
https://wiki.archlinux.org/title/Udev#X … is_present
Test for the presence of an xorg process or even better: import the environment from there (as well)
https://gist.github.com/AladW/de1c5676d93d05a5a0e1 (this is for xinit)

Online

#3 2023-06-15 20:56:52

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: Help writing udev rules to disable touchpad when plugging in usb mouse

Alternatively, just get rid of the dependency on X (and XAUTHORITY and DISPLAY) all together.  Identify the actual relevant device node (e.g., /sys/class/input/mouseN) then just have the udev rule write a 1 or 0 to /sys/class/input/mouseN/inhibited  . Alternatively, use one of the by-path nodes which might be more stable (the numbered nodes *might* change order between boots).

(edit: that may actually be easier yet with a udev command to set the attribute without invoking any external command - but I don't know the syntax for this off the top of my head).

Last edited by Trilby (2023-06-15 21:06:21)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB