nedelja, 23. september 2012

Toggle touchpad under Linux

If you want to toogle touchpad device under Linux, you have to do this:
sudo apt-get install unclutter

Put following lines into toggleTouchpad.sh:
          #!/bin/bash
deviceName="AlpsPS/2 ALPS DualPoint TouchPad"
isEnabled=`xinput --list-props "$deviceName" | grep -e "Device Enabled.*1$"`
if [ -n "$isEnabled" ]; then
    echo Disabling touchpad $deviceName
    xinput --set-prop "$deviceName" "Device Enabled" 0
    unclutter &
else
    echo Enabling touchpad $deviceName
    killall unclutter
    xinput --set-prop "$deviceName" "Device Enabled" 1
fi
 
Name of my touchpad device is AlpsPS/2 ALPS DualPoint TouchPad. You can find the list of all input devices issuing
xinput list
then you just have to guess what device it is :)
Then you can link this bash script to a keyboard shortcut and you are done.

There is also another way of doing this. Issu following command
synclient  TouchpadOff=1
If this command disables your touchpad then toogleTouchpad.sh might look like this:
#!/bin/bash

isEnabled=`synclient | grep -e ".*TouchpadOff.*0$"`

if [ -n "$isEnabled" ]; then
    echo Disabling device
    synclient TouchpadOff=1
    unclutter &
else
    echo Enabling device
    killall unclutter
    synclient TouchpadOff=0
fi
 

Ni komentarjev: