Bash – How to create script that toggles one value in synclient

bashshell-scriptsynclient

I use synclient touchpadoff=1 to disable touchpad and synclient touchpadoff=0 to enable touchpad.

$synclient | grep TouchpadOff
    TouchpadOff             = 1

I'd like to create script that will toggle this value. Then I will bind to key in OpenBox.

Best Answer

How about:

if synclient -l | egrep "TouchpadOff.*= *0" ; then 
    synclient TouchpadOff=1 ; 
else 
    synclient TouchpadOff=0 ; 
fi

For reference a third setting, TouchpadOff = 2, disables only tapping.


Or a one-liner:

synclient TouchpadOff=$(synclient -l | grep -c 'TouchpadOff.*0')

References:

Related Question