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)
In reply to Re: Detect standby/hibernation mode
by BrowserUk
in thread Detect standby/hibernation mode
by Sewi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |