As mentioned in a previous post, I mentioned about my HP Envy and Ubuntu. One more feature I noticed missing was the ability to enable and disable the touchpad. As shown in the picture, the touchpad has a special tap area on its left top corner which acts as a toggle button. But this is not working under Ubuntu. But ofcourse I had to solve this problem and here is the solution I came up with:
First of all we need to list all the input devices available. This can be done by the command:
⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ Logitech USB Receiver id=9 [slave pointer (2)] ⎜ ↳ Logitech USB Receiver id=10 [slave pointer (2)] ⎜ ↳ SynPS/2 Synaptics 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)] ↳ HP Truevision HD id=11 [slave keyboard (3)] ↳ AT Translated Set 2 keyboard id=12 [slave keyboard (3)] ↳ HP WMI hotkeys id=14 [slave keyboard (3)]
Notice the 4th entry under Virtual core pointer which is SynPS/2 Synaptics TouchPad having id=13. To be very sure we can also test it using the command:
xinput test 13
As I move my finger on the touchpad, the data is displayed which is a surety that I made the right choice. Now we need to create a script to enable/disable the touchpad.
Create a new file for instance toggle and place it in the current folder. Add the following contents to this file:
SYNSTATE=$(xinput list-props "13" | grep Enabled | grep -Eo '.$') if [ $SYNSTATE = 0 ]; then xinput set-prop "13" "Device Enabled" 1 else xinput set-prop "13" "Device Enabled" 0; fi
Notice the “13” in all three lines, this is the id which we noticed earlier. Save and close the file. To run this script, we need to change the permissions to executable:
chmod +x toggle
Finally we can enable and disable the touchpad:
Running this command will disable it, which you can test also. Running it again will enable it again. This is enough and works fine. However you will notice that these id numbers at times do change on different system boots. The solution can be to use the complete name its of the id in the script:
SYNSTATE=$(xinput list-props "SynPS/2 Synaptics TouchPad" | grep Enabled | grep -Eo '.$') if [ $SYNSTATE = 0 ]; then xinput set-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 1 else xinput set-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 0; fi
As an additional step, we can also assign a keyboard shortcut for this file. Open the Keyboard program from Unity dash and go to the second tab named Shortcuts. Add a new shortcut as shown in the picture. Give a name, path of the file and a key combination.
Now pressing these keys will toggle the touchpad :-)