Skip to content

Instantly share code, notes, and snippets.

@salaros
Last active January 23, 2018 18:02
Show Gist options
  • Save salaros/f941fcea673db36c6416f3c158959862 to your computer and use it in GitHub Desktop.
Save salaros/f941fcea673db36c6416f3c158959862 to your computer and use it in GitHub Desktop.
Disable touchpad via udev when mouse is plugged
# Disable touchpad when mouse is plugged
# file: /etc/udev/rules.d/01-touchpad.rules
ACTION=="add", ENV{ID_CLASS}="mouse",ENV{DISPLAY}=":0.0", ENV{XAUTHORITY}="/home/salaros/.Xauthority", RUN+="/bin/sh -c 'xinput disable DELL0767:00\ 06CB:7E92\ Touchpad'"
ACTION=="remove", ENV{ID_CLASS}="mouse", ENV{DISPLAY}=":0.0", ENV{XAUTHORITY}="/home/salaros/.Xauthority", RUN+="/bin/sh -c 'xinput enable DELL0767:00\ 06CB:7E92\ Touchpad'"
#!/bin/sh -e
# ....
# Checks if the mouse is connected and "re-adds" it in order to trigger udev rule
[[ -c /dev/input/mouse0 ]] && udevadm trigger --action=add --name-match=input/mouse0
exit 0
$ xinput
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=16 [slave pointer (2)]
⎜ ↳ Logitech USB Receiver id=10 [slave pointer (2)]
⎜ ↳ Logitech USB Receiver id=18 [slave pointer (2)]
⎜ ↳ DELL0767:00 06CB:7E92 Touchpad id=13 [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)]
↳ Integrated_Webcam_HD: Integrate id=12 [slave keyboard (3)]
↳ Dell WMI hotkeys id=14 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=15 [slave keyboard (3)]
↳ DELL Wireless hotkeys id=17 [slave keyboard (3)]
↳ Logitech USB Receiver id=11 [slave keyboard (3)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment