Is there any way by command-line (no softwares) to set a keyboard shortcut to toggle between 2 commands using the same shortcut key combination. Actually, i wanted to toggle my mousepad when using mouse.
Asked
Active
Viewed 267 times
0
1 Answers
1
Yes, it is possible. First you need to identify your touchpad. Run xinput list
(you might have to install xinput
with sudo apt install xinput
first). On my system, that shows:
$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ TPPS/2 IBM TrackPoint id=16 [slave pointer (2)]
⎜ ↳ Logitech USB Receiver id=12 [slave pointer (2)]
⎜ ↳ Logitech M325 id=10 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=15 [slave pointer (2)]
⎜ ↳ Logitech USB Receiver id=11 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Sleep Button id=9 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Integrated Camera id=13 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Logitech USB Receiver id=18 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=14 [slave keyboard (3)]
↳ Video Bus id=8 [slave keyboard (3)]
↳ ThinkPad Extra Buttons id=17 [slave keyboard (3)]
So, my touchpad is called SynPS/2 Synaptics TouchPad
. Find out the name of yours and then modify this script accordingly:
#!/bin/bash
## Change this value to whatever your touchpad is called
touchpad='SynPS/2 Synaptics TouchPad'
status=$(xinput list-props "$touchpad" | grep "Device Enabled" | gawk '{print $NF}');
if (( $status==1 )); then
xinput -set-int-prop "$touchpad" "Device Enabled" 8 0
else
xinput -set-int-prop "$touchpad" "Device Enabled" 8 1
fi
Save that script as ~/bin/toggle_touchpad.sh
and then use your desktop environment's GUI to assign a shortcut to it. The shortcut will now run the script and toggle the touchpad as desired.

terdon
- 100,812
xinput list
. – terdon Aug 18 '17 at 13:20