in reply to Detect standby/hibernation mode

One simple mechanism would be to run a background thread that check the time once per second and sets a flag if the difference between this time and last time is greater than (say) 2 seconds. This 'worked' for me:

#! perl -slw use strict; use threads; use threads::shared; my $sem :shared = 0; async { my $last = time; while( sleep 1 ) { my $now = time; if( $now - $last > 2 ) { $sem = 1; } $last = $now; } }->detach; while( sleep 1 ) { print "tum te tum"; if( $sem ) { print "You snoozed me"; $sem = 0; } } __END__ C:\test>junk96 tum te tum tum te tum tum te tum tum te tum tum te tum tum te tum tum te tum tum te tum tum te tum You snoozed me tum te tum tum te tum tum te tum tum te tum Terminating on signal SIGINT(2)

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.