06 October 2013

HOWTO: Toggle on/off the touchpad of your notebook in linux

In case you may get annoyed when typing in your favorite editor in Linux by touching the Mouse Touchpad by mistake and doing strange actions, you can choose to temporarily disabled it.
Here is a little script, you can run it once per session and it won't be permanent after a reboot.
This has been tested under CentOS 6.x and RedHat 6.x

$ cat ~/touch-toggle.sh

#!/bin/bash


DEVID=$(xinput list|grep "PS/2 Generic Mouse"|sed -r 's,.*id=([0-9]+).*,\1,')

CRTSTATE=$(xinput list-props $DEVID|grep "Device Enabled"|sed -r 's,.*([0-1]),\1,')
NEWSTATE=$(expr 1 - $CRTSTATE)

echo "Toggle touchpad to new state: $NEWSTATE"

xinput set-int-prop $DEVID "Device Enabled" 8 $NEWSTATE

No comments:

Post a Comment