Recently, my wife (who knows I'm addicted to anything with blinking LEDs on it) suggested that I might hook a monitor to my headless Linux box and have it display just blinking lights in the screen. Once I tore myself away from staring at the modem and ethernet hub, I took a crash course in Curses and threw together the following script.

Of course, now I want to add more monitors to the box just to have more things blinking at me ;)

#!/usr/bin/perl -wT use strict; use Curses; my $win = new Curses; my ($x, $y, $color,$bold,$char); initscr; start_color; # Initialize the 6 color pairs I'll use init_pair 1, COLOR_GREEN, COLOR_BLACK; init_pair 2, COLOR_RED, COLOR_BLACK; init_pair 3, COLOR_YELLOW, COLOR_BLACK; init_pair 4, COLOR_BLUE, COLOR_BLACK; init_pair 5, COLOR_MAGENTA, COLOR_BLACK; init_pair 6, COLOR_CYAN, COLOR_BLACK; init_pair 7, COLOR_BLACK, COLOR_WHITE; halfdelay(1); #wait for 1/10 secs for keystroke noecho; #don't echo keystrokes # Loop to continuously blink the lights while (1) { $x = int(rand(79)); $y = int(rand(23)); $color = int(rand(8)); # use one of my 7 color pairs $bold = int(rand(2)); # Use a space as my character $char = 32|COLOR_PAIR($color)|A_REVERSE; if ( $bold > 0 ) { $char = $char|A_BOLD; } $win->addch($y,$x,$char); $win->refresh; # exit loop when a key is pressed last unless ($win->getch() eq -1); } endwin;

In reply to blinkenlights by rattusillegitimus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.