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

How to set the automatic disable touch pad after plugging in the external mouse

Hi @ranaground, and welcome!

After some googling I found this reddit question stating:

You need to make sure you install libinput. Then it’ll be under Pointing Devices, rather than touchpad settings

So, I’m guessing it has to do with that. And libinput is in the extra repositories:

$ pamac search libinput
[...]
libinput                                                                                                                                                                                                    [Installed] 1.19.3-1                  extra
Input device management and event handling library

So, in theory it can be installed with:

pamac install libinput

However, I see many libinput- packages there, and it might easily be one of/none of them and I wouldn’t know, nor would anyone else without additional information.

First maybe you could check if something like the following works:

xinput disable $(xinput list | grep -i touchpad | awk -F'[^0-9]*' '{print $7}')
xinput enable $(xinput list | grep -i touchpad | awk -F'[^0-9]*' '{print $7}')

Then I say
Maybe a script and/or env var and udev rule?

example:

/etc/environment

tch=$(xinput list | grep -i touchpad | awk -F'[^0-9]*' '{print $7}')

/etc/udev/rules.d/66-touchpadoff.rules

KERNEL=="mouse*", ATTRS{phys}=="usb*", ACTION=="add", \
  RUN+="/usr/bin/xinput disable "$tch""
KERNEL=="mouse*", ATTRS{phys}=="usb*", ACTION=="remove", \
  RUN+="/usr/bin/xinput enable "$tch""
1 Like

@cscs xorg-xinput should be installed to carry out this command

@ranaground also see this thread

A terminal prompt

zsh: correct ‘xinput’ to ‘_xinput’ [nyae]?

Need to install additional packages?

1 Like

sudo xinput disable $(xinput list | grep -i touchpad | awk -F’[^0-9]*’ ‘{print $7}’)

X Error of failed request: BadAccess (attempt to access private resource denied)
Major opcode of failed request: 131 (XInputExtension)
Minor opcode of failed request: 57 ()
Serial number of failed request: 21
Current serial number in output stream: 22

Seems to have encountered an error

What is the output of xinput list

⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ ALP001A:00 044E:121B Mouse                id=13   [slave  pointer  (2)]
⎜   ↳ ALP001A:00 044E:121B Touchpad             id=14   [slave  pointer  (2)]
⎜   ↳ PS/2 Generic Mouse                        id=17   [slave  pointer  (2)]
⎜   ↳ RAPOO Rapoo 2.4G Wireless Device Consumer Control id=12   [slave  pointer  (2)]
⎜   ↳ RAPOO Rapoo 2.4G Wireless Device Mouse    id=11   [slave  pointer  (2)]
⎜   ↳ AlpsPS/2 ALPS GlidePoint                  id=21   [slave  pointer  (2)]
⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Video Bus                                 id=7    [slave  keyboard (3)]
    ↳ Power Button                              id=8    [slave  keyboard (3)]
    ↳ Sleep Button                              id=9    [slave  keyboard (3)]
    ↳ ALP001A:00 044E:121B UNKNOWN              id=15   [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard              id=16   [slave  keyboard (3)]
    ↳ HP WMI hotkeys                            id=18   [slave  keyboard (3)]
    ↳ Wireless hotkeys                          id=19   [slave  keyboard (3)]
    ↳ RAPOO Rapoo 2.4G Wireless Device          id=10   [slave  keyboard (3)]
    ↳ RAPOO Rapoo 2.4G Wireless Device Consumer Control id=20   [slave  keyboard (3)]

Mk… So how does this go:

xinput disable 'ALP001A:00 044E:121B Touchpad'
xinput enable 'ALP001A:00 044E:121B Touchpad'

(I noticed above you added ‘sudo’ - do not, it is not required)

If it works … you can use the udev rule:

/etc/udev/rules.d/66-touchpadoff.rules

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'"

Considering the touchpad had ID 14:

I think a shorter, and less error-prone command would be:

  • To disable the touchpad:
xinput --disable 14
  • To enable the touchpad:
xinput --enable 14

Or, well, perhaps not.

Yes, But I dont want that to change because of some configuration, update, hardware difference.
(thats what I was doing with awk above … just, dynamically)
So the name, since we were given the data, is more reliable.

True, I get it now.

Nothing is printed when the above command is executed.
It looks like it worked.

I’m going to write this information to ‘66-touchpadoff.rules’?

1 Like

Nothing should. But the touchpad should not work after disable, then work again after enable.

Yes … well, to be clear, the full path: /etc/udev/rules.d/66-touchpadoff.rules
ex:

sudo nano /etc/udev/rules.d/66-touchpadoff.rules

@cscs Do I need to reboot my computer to take effect

sudo udevadm control --reload

Also unplug/plug your usb again.

Otherwise, sure, reboot :wink:

I’m a Bluetooth device sorry

Whether it needs to be changed

WOW. I can’t believe how far technology has come!

1 Like