How to set the automatic disable touchpad after plugging in the external mouse?

Please revise to:

KERNEL=="mouse*", SUBSYSTEM=="bluetooth*", ATTR{type}=="bluetooth", ACTION=="add", \
  RUN+="/usr/bin/xinput disable 'ALP001A:00 044E:121B Touchpad'"
KERNEL=="mouse*", SUBSYSTEM=="bluetooth*", ATTR{type}=="bluetooth", ACTION=="remove", \
  RUN+="/usr/bin/xinput enable 'ALP001A:00 044E:121B Touchpad'"

KERNEL=="mouse*", ATTRS{phys}=="usb*", ACTION=="add", \
  RUN+="/usr/bin/xinput disable 'ALP001A:00 044E:121B Touchpad'"
KERNEL=="mouse*", ATTRS{phys}=="usb*", ACTION=="remove", \
  RUN+="/usr/bin/xinput enable 'ALP001A:00 044E:121B Touchpad'"

Then ā€¦ lets also move it up the chain:

sudo mv /etc/udev/rules.d/66-touchpadoff.rules /etc/udev/rules.d/99-touchpadoff.rules

donā€™t succeed

And you said it worked before, briefly?

@cscs yes

I guess, the main difference might be the second entry? Try again without it just to check.

Also we did perform a reload, so maybe check if that somehow kicks it in:

sudo udevadm control --reload

EDIT:
And maybe we could go about it another way. Try with this content:

SUBSYSTEM=="input", KERNEL=="mouse[0-9]*", ACTION=="add", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/ranaground/.Xauthority", RUN+="/usr/bin/xinput enable 'ALP001A:00 044E:121B Touchpad'"
SUBSYSTEM=="input", KERNEL=="mouse[0-9]*", ACTION=="remove", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/ranaground/.Xauthority", RUN+="/usr/bin/xinput disable 'ALP001A:00 044E:121B Touchpad'"

Note that I used ranaground as the username, please replace with username on desktop system.

1 Like

donā€™t succeed

donā€™t succeed

in command 'hwdb --subsystem=hid'
0018:044E:121B.0001: hwdb modalias key: "hid:b0018g0004v0000044Ep0000121B"

Does this have anything to do with it? ā€˜Hidā€™.

Thats for your touchpad, when we are trying to recognize the bt.

ā€¦honestly I am not sure why its not working. :confused:
Maybe I have overlooked something. Hopefully someone else stops by with a better suggestion.

what is it?
Touch padļ¼Ÿ

Is it feasible to disable ā€˜hidā€™ directly?

hid standing for Human Input Device, AFAIK, not likelyā€¦

ranaground means , he has bluetooth device .

This worked for me, but instead the touch pad works only when there is an external mouse attached. I flipped the code and now it works perfectly. (Remember to change {username} with your username, and {touch pad name} with the device name of your touchpad listed on xinput).

code:

SUBSYSTEM=="input", KERNEL=="mouse[0-9]*", ACTION=="add", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/{username}/.Xauthority", RUN+="/usr/bin/xinput disable '{touch pad name}'"
SUBSYSTEM=="input", KERNEL=="mouse[0-9]*", ACTION=="remove", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/{username}/.Xauthority", RUN+="/usr/bin/xinput enable '{touch pad name}"

example:

SUBSYSTEM=="input", KERNEL=="mouse[0-9]*", ACTION=="add", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/snich/.Xauthority", RUN+="/usr/bin/xinput disable 'DLL07BD:00 06CB:75BF Touchpad'"
SUBSYSTEM=="input", KERNEL=="mouse[0-9]*", ACTION=="remove", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/snich/.Xauthority", RUN+="/usr/bin/xinput enable 'DLL07BD:00 06CB:75BF Touchpad'"

The only problem now is that the rule will only be triggered when a mouse is unplugged/plugged-in. So, when there is a mouse already plugged-in on startup, the rule will not work as it didnā€™t detected the mouse got plugged-in. Just correct me if Iā€™m wrong. Iā€™m no Linux expert. @cscs maybe you know a hack for this.

You could try removing ACTION=="add",, or rewrite the rule for disabling the touchpad.

You could trigger an add action in a startup script.

https://wiki.archlinux.org/title/Udev#Triggering_events

1 Like

I donā€™t know much about udevadm, bash other things about Linux yet, but I know programming.

I created this script instead and it runs when I log-in.

#!/usr/bin/zsh

udevadm info /dev/input/by-id/*-mouse || check=0

if [[ $check == 0  ]]
then
    /usr/bin/xinput enable 'DLL07BD:00 06CB:75BF Touchpad'
    echo 'Touchpad enabled. No external mouse detected.'
else
    /usr/bin/xinput disable 'DLL07BD:00 06CB:75BF Touchpad'
    echo 'Touchpad disabled. External mouse detected.'
fi