Enable/disable touchpad
I managed to install Ubuntu 16.04 on my asus ux501 vw, but some of my shortcut are not working. I'm not looking to fix them all, but just one : the shortcut which allow me to enable or disable touchpad, so i can write long documents with working about the touchpad.
I tried to find it on google but I got nothing.
Can someone explain me how to fix that please? Thanks !
Solution 1:
I created this bash script from negusp's answer. It finds and toggles TouchPad device. You can configure a custom shortcut to it in system settings.
#!/bin/bash
read TPdevice <<< $( xinput | sed -nre '/TouchPad|Touchpad/s/.*id=([0-9]*).*/\1/p' )
state=$( xinput list-props "$TPdevice" | grep "Device Enabled" | grep -o "[01]$" )
if [ "$state" -eq '1' ];then
xinput --disable "$TPdevice" && notify-send -i emblem-nowrite "Touchpad" "Disabled"
else
xinput --enable "$TPdevice" && notify-send -i input-touchpad "Touchpad" "Enabled"
fi
I'm setting Ctrl+Shift+F9 for toggle touchpad enable and disable like this:
Update: You may need to make your script to executable with command chmod +x filename or input /bin/bash /filepath to Command field of Custom shortcut window.
Solution 2:
You want shortcut, but you can easily put 2 scripts on the desktop and execute them.
First, go to terminal. Type xinput
.
Output Example:
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=12 [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)]
↳ Laptop_Integrated_Webcam_1.3M id=10 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=11 [slave keyboard (3)]
↳ Dell WMI hotkeys
Find the Touchpad. In this example, the touchpad is listed as id=12
Create the first script with this:
#!/bin/bash
xinput enable 12
Save it and name it touchpadenable.sh
, and in terminal, mark it as executable with:
chmod +x touchpadenable.sh
Do the exact same thing again, but rename the file as touchpaddisable.sh
(or whatever), and instead of
xinput enable 12
Use the command
xinput disable 12
Save, mark as executable, and you should be able to run the scripts from the desktop. Note: you may have to right-click the scripts, click properties, and allow it to be executed.
Solution 3:
You must to do like negusp's answer, first check your touch device, and will shows something like this:
~$ xinput ⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ PixArt Dell MS116 USB Optical Mouse id=10 [slave pointer (2)] ⎜ ↳ SynPS/2 Synaptics TouchPad id=14 [slave pointer (2)] ⎜ ↳ DLLC6B2:00 06CB:75BF Touchpad id=12 [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 id=11 [slave keyboard (3)] ↳ AT Translated Set 2 keyboard id=13 [slave keyboard (3)] ↳ Dell WMI hotkeys id=15 [slave keyboard (3)] ↳ DELL Wireless hotkeys id=16 [slave keyboard (3)]
In my case is the device with id=12, now create a bash script with name "toggle-touch" in you Desktop folder under a folder named "bin", would be "~/Desktop/bin" and copy next code, check the device variable is pointed to my touch id=12, fix it with your case:
#!/bin/bash
device=12
state=`xinput list-props "$device" | grep "Device Enabled" | grep -o "[01]$"`
if [ $state == '1' ];then
xinput --disable $device
else
xinput --enable $device
fi
Set to this script execution permission:
chmod 775 /Desktop/bin/toggle-touch
Finally you can add this path to the ".bashrc" from your home folder, just add this line to the end of file:
PATH=$PATH:~/Desktop/bin
update the path with:
. .bashrc
Then you can execute this script from any place, I hope this help.