[Ubuntu Tip] Touch en/disable Hot Key by kdj

View this thread on steempeak.com
· @kdj ·
$0.85
[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)
![shortcuts.png](https://steemitimages.com/DQmZf6oK5frktPbijWAxkUVjs1t2Ttkop35uvtx2fodn9qL/shortcuts.png)
## 6. Test Shortcut
Does shortcut enable/disable touch well?

Protect your typing from unintentional touch pad.
Thank you.
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 46 others
properties (23)
post_id2,108,518
authorkdj
permlinkubuntu-tip-touch-en-disable-hot-key
categorylinux
json_metadata"{"app": "steemit/0.1", "format": "markdown", "image": ["https://steemitimages.com/DQmZf6oK5frktPbijWAxkUVjs1t2Ttkop35uvtx2fodn9qL/shortcuts.png"], "tags": ["linux", "ubuntu", "laptop", "touch", "touchpad"]}"
created2017-03-08 16:31:45
last_update2017-03-08 16:31:45
depth0
children1
net_rshares10,371,204,556,848
last_payout2017-04-08 17:02:27
cashout_time1969-12-31 23:59:59
total_payout_value0.670 SBD
curator_payout_value0.177 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length2,143
author_reputation4,190,079,105,786
root_title"[Ubuntu Tip] Touch en/disable Hot Key"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (110)
@salimch ·
https://steemitimages.com/0x0/http://www.reactiongifs.com/r/crwdc.gif
properties (22)
post_id15,442,275
authorsalimch
permlinkre-kdj-ubuntu-tip-touch-en-disable-hot-key-20171016t154856441z
categorylinux
json_metadata"{"app": "steemit/0.1", "image": ["https://steemitimages.com/0x0/http://www.reactiongifs.com/r/crwdc.gif"], "tags": ["linux"]}"
created2017-10-16 15:49:00
last_update2017-10-16 15:49:00
depth1
children0
net_rshares0
last_payout2017-10-23 15:49:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length69
author_reputation1,063,326,571,637
root_title"[Ubuntu Tip] Touch en/disable Hot Key"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000