Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of rafael (2125)

Thursday February 20, 2003
03:44 PM

TULCSS

[ #10709 ]
#!/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__
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.