scripts/sway/idlecountdown.pl

26 lines
808 B
Perl
Raw Normal View History

#!/usr/bin/perl
use strict;
use warnings;
use Gtk2::Notify -init, "Idle";
use Time::HiRes qw( gettimeofday usleep );
my $start = [gettimeofday];
my $now = sprintf("%.0f",($start->[0]*1000) + ($start->[1]/1000));
my $end = $now + 30000;
while ($now < $end) {
2023-01-06 19:41:31 +00:00
my $remaining = ($end - $now);
my $notification = Gtk2::Notify::new('Idle', sprintf("%.0f",($remaining/1000)), '', "status_lock");
$notification->set_hint_string('x-canonical-private-synchronous','idle');
$notification->set_urgency('NOTIFY_URGENCY_LOW');
$notification->set_hint_int32('value',($remaining/300));
$notification->set_timeout(150);
$notification->show();
usleep(100);
$now = utime( undef, undef );
$start = [gettimeofday];
$now = sprintf("%.0f",($start->[0]*1000) + ($start->[1]/1000));
}