touchpad.sh (792B)
1 #!/bin/sh 2 # 3 # touchpad 4 5 main() { 6 # get touchpad using xinput 7 # xinput will show list of input devices with id (we want id) 8 # we can then use xinput list-props <ID> to see if device enabled 9 tp="$(xinput | grep -i '^.*touchpad.*id=[0-9][0-9]*.*$' | awk '{ for (i = 1; i <= NF; i++) { if ($i ~ /^.*id=[0-9][0-9]*.*$/) { print $i } } }' | tr -d -c 0-9)" 10 flag="$(xinput list-props "${tp}" | grep -i '^.*device enabled.*$' | awk '{ for (i = 1; i <= NF; i++) { if ($i ~ /^\s*[0-1]\s*$/) { print $i } } }')" 11 12 # toggle touchpad also with xinput 13 { 14 if [ "${flag}" -eq 1 ]; then xinput --disable "${tp}" && env HERBE_ID=/0 herbe 'Touchpad disabled' & 15 else xinput --enable "${tp}" && env HERBE_ID=/0 herbe 'Touchpad enabled' & 16 fi 17 } & 18 } 19 20 main "${@}"