summaryrefslogtreecommitdiffstats
path: root/src/perl/digital-clock
blob: 7adddde3338eba257b310e66453dac7fefdcad6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#! perl

=head1 NAME

digital-clock - display a digital clock overlay

=head1 DESCRIPTION

Displays a digital clock using the built-in overlay.

=cut

sub on_start {
   my ($self) = @_;

   $self->{overlay} = $self->overlay (-1, 0, 8, 1, urxvt::OVERLAY_RSTYLE, 0);
   $self->{timer} = urxvt::timer
                    ->new
                    ->start (1 + int urxvt::NOW) # make sure we update "on" the second
                    ->interval (1)
                    ->cb (sub {
                       $self->{overlay}->set (0, 0,
                          sprintf "%2d:%02d:%02d", (localtime urxvt::NOW)[2,1,0]);
                    });

   ()
}