Monday, October 29, 2012

Script to on/off touchpad on Ubuntu 12.04

I wrote this is for workaround for those touchpad button & fn key is not working.


1 )  Create file ~/tp.sh with content below.

#!/bin/bash


off=`sudo synclient |grep TouchpadOff |cut -c30-35`

if [ $off -eq 0 ] ;then
echo 'turnoff touchpad';
sudo synclient TouchpadOff=1
else
echo 'turnon touchpad';
sudo synclient TouchpadOff=0
fi


2 ) sudo chmod +x ~/tp.sh

3 ) Adding shortcut by launch Settings > Keyboard, go to tab 'Shorcuts'
 Click '+' icon for adding new shortcut.
Name: Touchpad On/Off
Shortcut: sudo ~/tp.sh
 
Click 'Apply', then click on Disable to select shortcut key, my case is Super+f9 since Fn will not work here.

4 ) Grant permission
adding line below to sudoer and replace <user> to your username.
<user> ALL = (ALL) NOPASSWD: /home/<user>/tp.sh

Enjoy!

1 comment:

  1. Better one.
    http://alexsleat.co.uk/2012/03/22/toggle-touchpad-with-keyboard-shortcut-in-ubuntu/

    ReplyDelete