I investigated how to prevent my phone from going to sleep while using SSH. Currently default_hooks/sxmo_hook_check_state_mutexes.sh checks using the following command for a running SSH session:
netstat -tn | grep ESTABLISHED | cut -d':' -f2 | grep -q '^22 '
As IPv6 addresses contain colons itself, this only works for IPv4. I would suggest to change this to the following:
netstat -tn | grep ESTABLISHED | cut -d\ -f16 | grep -q ':22$'
(or, for easier readibility, but with new dependency on preinstalled awk):
netstat -tn | grep ESTABLISHED | awk '{ print $4 }' | grep -q ':22$'
We already do this in master:
(similar to your last one)
ssh_connected() { netstat -tn | awk ' BEGIN { status = 1 } $4 ~ /:22$/ { status = 0; exit } END { exit status } ' } # active_ssh if ssh_connected; then lock_suspend_mutex "SSH is connected" else free_suspend_mutex "SSH is connected" fi
Also if ssh runs on non-standard port...
For those cases, you can edit your sxmo_hook_check_mutexes.sh.