I might rewrite the loop in the following way to be sure that the action is triggered the first time the script is woken up after a target number of seconds.
Or to be even fancier and extensible-er:sleep 1 until time - $llent->ll_time >= 1800; passive_pop("Thirty minutes"); sleep 1 until time - $llent->ll_time >= 3600; passive_pop("One hour"); sleep 1 until time - $llent->ll_time >= 5400; passive_pop("Ninety minutes"); sleep 1 until time - $llent->ll_time >= 7200; passive_pop("Two hours"); tattle_tail();
Also, it appears that your code as written will loop forever. This may be fine if your KDE autostart things get automatically killed when he logs out, but is something to consider.my %actions = ( 1800 => sub { passive_pop("Thirty minutes"); }, 3600 => sub { passive_pop("Sixty minutes"); }, 5400 => sub { passive_pop("Ninety minutes"); }, 7200 => sub { passive_pop("Two hours"); tattle_tail(); }, # 8000 => sub { disable_network_interface(); }, # 9999 => sub { self_destruct(); } ); for my $duration (sort {$a <=> $b} keys %actions) { sleep 1 until time - $llent->ll_time >= $duration; $actions{$duration}->(); }
blokhead
In reply to Re: Reminder for KDE Kid
by blokhead
in thread Reminder for KDE Kid
by KennV
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |