TULCSS

rafael on 2003-02-20T20:44:35

#!/usr/bin/perl

=head1 NAME

tulcss - The Totally Useless Linux Console Screen Saver

=head1 SYNOPSIS

./tulcss &

or, to specify a number of seconds after which the screen saver will be activated :

./tulcss 240 &

=head1 NOTES

I don't understand the Linux kernel well enough to know whether this code is reasonably portable across different Linux installations.

=cut

use strict; use warnings; my $IDLE = shift || 60; # seconds my $int = 0; my $timer = time; my $l = 1311131333; $l =~ s/./\033[4$&m \033[0m/g; while (sleep 1) { open my $fh, "/proc/interrupts" or die $!; while (<$fh>) { if (/\d:\s*(\d+).*keyboard/) { if ($1 != $int) { $int = $1; $timer = time; } last; } } close $fh; if (time - $timer > $IDLE) { # Oooh, pretty pictures print "$l$l$l$l\n"; $l =~ s/(.*)(.{33})/$2$1/; } }

__END__