The script has a /bin/sh shebang but the [[ test construct is undefined in POSIX.
I would use $(...) instead of backticks and also awk instead of grep & cut so:
Code:
#!/bin/sh
tp_state=$(doas wsconsctl 2>/dev/null | awk -F'=' '/mouse.tp.disable/{print $2}')
if [ "$tp_state" -eq 0 ] ; then
doas wsconsctl mouse.tp.disable=1 1>/dev/null
else
doas wsconsctl mouse.tp.disable=0 1>/dev/null
fi
Not sure why you've used backticks around the then & else commands but perhaps I've missed something there.