[Ubuntu Tip] Touch en/disable Hot Key
Hi, laptop linux users.
Most laptop have a touchpad problem that it sometimes is touched when pressing keys, which annoying me when I making codes.
I realized that I don't need touchpad enabled while eagerly pressing keys, so I decide make a hotkey enable/disable touchpad.
1. Open terminal
$ xinput
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Logitech USB Receiver id=11 [slave pointer (2)]
⎜ ↳ ETPS/2 Elantech Touchpad id=14 [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)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ Power Button id=9 [slave keyboard (3)]
↳ Logitech USB Receiver id=10 [slave keyboard (3)]
↳ LG HD WebCam id=12 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=13 [slave keyboard (3)]
2. Try the command
$ xinput set-prop 14 "Device Enabled" "0"
Touch pad id is 14 (Elantech Touchpad)
Last "0" means disable touch, and "1" enable.
3. It's time to make a shell script.
Make "toggletouch.sh" in the $PATH directory.
#!/bin/bash
DNAME="Touchpad"
DEV=`xinput --list | grep "$DNAME"|cut -d= -f2|cut -c1,2`
STATE=`xinput list-props "$DEV" | grep "Device Enabled" | cut -f3`
if [ "$STATE" == "0" ]; then
SWITCH="1"
else
SWITCH="0"
fi
xinput set-prop "$DEV" "Device Enabled" "$SWITCH"
If your touch device doesn't have sub string "Touchpad", you need to change it.
DEV is 14 in the above xinput list.
STATE catches the current state "0" or "1"
4. Test toggletouch.sh
$ toggletouch.sh
Does it toogle touch enable/disable well?
5. Making a Shortcut
- Go to System settings -> keyboard -> shortcuts
- Add new in Custom Shortcuts { name: toggle touch, command: toogletouch.sh }
- Assign a ShortCut (Here shift +alt + T)
6. Test Shortcut
Does shortcut enable/disable touch well?
Protect your typing from unintentional touch pad.
Thank you.
Sort: Trending
[-]
salimch (52) 7 years ago