I use #OpenBSD on my laptops, so I have a few helper scripts that will run when I suspend and resume the laptop.
All of this is documented in http://man.openbsd.org/apmd.8 so please check out the documentation in the man page.
/etc/apm/suspend:
/usr/bin/pkill -USR1 -x xidle
# EOF
by sending the USR1 signal to xidle, it will automatically run xlock. When I suspend, my laptop will require a password to get access to X after resume.
(yes, xlock is not 100% secure, but this is a good step)
#OpenBSD cont
lladdr random changes my mac address of my network interface, which will trigger new IPv4 and IPv6 addresses for my laptop, hopefully preventing any network-based tracking. (this is also why I pkill ssh and ftp. with new IPs, those *cannot* keep their sessions after I wake.)
I will occasionally write emails on my laptop; so scheduling all email will ensure that everything is pushed out. I sleep 60s there in case I need to play with a captive portal.
And to finish this up, I have
apmd_flags=-A -z 5
in my rc.conf.local config file.
This tells apmd to run in automatic performance mode, so it will adjust your cpu frequency up when you are using cpu, and adjust it down when your machine is idle. slower cpu frequencies will save a lot of power, potentially up to another 50%-100% of batt life!
-z 5 will suspend my laptop when battery percentage is below 5. KEEP IN MIND that this value is inexact, and is checked less often than you may hope.
@phessler Thanks for the detail. I'm unfortunately not using my personal laptop anywhere near as much as I would like, and 95% of the time it's used at home, so my needs wrt. suspend/hibernate are not critical at all. However, it's interesting and useful to understand how people with much more demanding requirements set it up
my #OpenBSD resume script is a bit more complicated.
/etc/apm/resume:
pkill -x ssh ftp
/sbin/ifconfig em0 -inet down
/sbin/ifconfig iwm0 -nwid
/sbin/ifconfig iwm0 lladdr random
(sleep 60; smtpctl schedule all) &
#EOF
I kill off any ssh and ftp connections immediately, instead of waiting for them to time out.
I down the em0 interface, which I hardly ever use for $reasons.
-nwid will remove any manual wifi config, so auto-join will kick in and join any network I have saved.
(cont)