satan's little suckass demonstration (greck) wrote,
satan's little suckass demonstration
greck

Perl code du jour...

#!/usr/bin/perl

$delayMIN = 5;
$delayMAX = 30;

opendir DIR, "$ENV{HOME}/.wallpaper";
@images = grep !/^\.\.?$/, readdir DIR;
closedir DIR;

system "xv +noresetroot -root -quit $ENV{HOME}/.wallpaper/$images[int(rand scalar @images)] > /dev/null 2> /dev/null" and exit;

$delay = int(rand($delayMAX - $delayMIN)) + $delayMIN;

open AT, "|at now + $delay minutes > /dev/null 2> /dev/null";
print AT "DISPLAY=$ENV{DISPLAY}; export DISPLAY\n";
print AT "wallpaper.pl\n";
close AT;


It even bails in a friendly, quiet way if the display is unavailable; you can just kick it off in your .xinitrc or whatever.
Subscribe

  • (no subject)

    I promised kitara and dakus that I'd be getting with the program again by 8/2 because I want to document more about my trip…

  • (no subject)

    Season's Greetings! to all and their families. Please note my lack of putting words into boxes here is no indication of lack of reading several…

  • (no subject)

    links of the morning, via N.F. Autistic savant draws Rome from memory.</> Japanese men running in synchronized slow motion.[1] Donald in…

  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 10 comments

  • (no subject)

    I promised kitara and dakus that I'd be getting with the program again by 8/2 because I want to document more about my trip…

  • (no subject)

    Season's Greetings! to all and their families. Please note my lack of putting words into boxes here is no indication of lack of reading several…

  • (no subject)

    links of the morning, via N.F. Autistic savant draws Rome from memory.</> Japanese men running in synchronized slow motion.[1] Donald in…