summaryrefslogtreecommitdiffstats
path: root/src/perl/digital-clock
diff options
context:
space:
mode:
authorroot <root>2012-09-04 22:41:11 +0000
committerroot <root>2012-09-04 22:41:11 +0000
commitd50a22a63f36f3d4fb5bd2f4d7d0f89f36d84e8f (patch)
tree64566414b54ff274345437c2b02a4f1e73b80e72 /src/perl/digital-clock
parent5ee396e7ac453f939e8ec74546756dba45906827 (diff)
*** empty log message ***
Diffstat (limited to 'src/perl/digital-clock')
-rw-r--r--src/perl/digital-clock29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/perl/digital-clock b/src/perl/digital-clock
new file mode 100644
index 0000000..7adddde
--- /dev/null
+++ b/src/perl/digital-clock
@@ -0,0 +1,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]);
+ });
+
+ ()
+}
+
+