Re:Caffeine-like utility to keep you MacBook awake with its ...
by clash on Friday October 23, 2026 @09:22PM
(#50217532)
Can your one line terminal invocation automatically put the MacBook to sleep when you are connected via ssh and the connection is lost?
[ Parent
| on HN ]
Re:Caffeine-like utility to keep you MacBook awake with its ...
by nomel on Friday October 23, 2026 @10:00PM
(#50217722)
Technically one line ;)
sudo bash -c 'trap "pmset -a disablesleep 0" EXIT; s=; while :; do if lsof -nP -iTCP:22 -sTCP:ESTABLISHED >/dev/null 2>&1 || pgrep -xq ssh;
then n=1; else n=0; fi; [ "$n" != "$s" ] && pmset -a disablesleep $n && s=$n; sleep 10; done'