12.14.2011

Linux - Script to Toggle Touchpad

Short script to toggle the touchpad on/off in Linux.
Comes in real handy if you want to map it to a keybinding in openbox.

#!/bin/bash
if [ $(synclient -l | grep TouchpadOff | awk '{print $3}') == 1 ] ; then
synclient touchpadoff=0;
else
synclient touchpadoff=1;
fi

In openbox I mapped this to my fn + f8 key (the default button to toggle the touchpad on my T420)
I added the following to ~/.config/openbox/rc.xml

<keybind key="XF86TouchpadToggle">
<action name="Execute">
<startupnotify>
<enabled>true</enabled>
<name>toggletouchpad</name>
</startupnotify>
<command></command>~/bin/toggletouchpad.sh
</action>

If you aren't sure what the key presses are that you want to use, there is a program called "xev" that will tell you the xevents keybindings, mousebindings etc. to the actions you are doing.

No comments:

Post a Comment