I am trying to save power by switching desktops to suspend mode when they are inactive. But many desktops are also accessed via SSH by their owners. There is a wakeonlan solution deployed to enable owners to switch on the machine, but the problem is that machines will auto-suspend again in 10 minutes, even though the SSH connection is on.
What I am trying to do is to include the active SSH sessions in the "activity" definitions.
The question is can it be done via setting a polkit rule? Can it be done via putting a script that runs before the actual suspend, and aborts it if SSH sessions are found? I need a clean legit way of doing this. If not that, then hacky ways are also welcome.
Current naive hacky solution: edit
#check for SSH sessions, and prevent suspending: if [ "$(who | grep -cv "(:")" -gt 0 ]; then echo "SSH session(s) are on. Not suspending." exit 1 fi
This serves the purpose. But I don't know when an update will overwrite the file
/usr/sbin/pm-suspend. I also don't know how this will work with other suspend implementations like tuxonice.