Nothing meaty here. Just something I whipped up to rotate my background in Window Maker.

Credit for a few of the lines goes to anithri's post.

#!/usr/local/bin/perl -w # # wmrotator.pl # # Created: Aug 14, 2003 by Andy Harrison # # $Id: wmrotator.pl,v 1.2 2003/08/25 19:29:23 aharriso Exp aharriso $ # # simple background/theme rotator for windowmaker, runs as a daemon # # Usage: # # Add to your $HOME/GNUstep/Library/WindowMaker/autostart script # # Create a file called bg.txt in your GNUstep dir with the filenames # from the Backgrounds directory, one per line. # # Similarly, you can create a file called themes.txt in your GNUstep # Themes dir with the directory name (the directory must contain a # style file) or the name of a style file in GNUstep Themes directory. # # In Window Maker, create a menu item with the command: # kill -USR1 `cat $HOME/GNUstep/rotatebg.pid` # and it will send a signal to rotate the background immediately. use strict; use Tie::File; use Proc::Daemon; my $rotatetime = 1200; my $GNUstep = "$ENV{'HOME'}/GNUstep"; my $bgdir = "$GNUstep/Library/WindowMaker/Backgrounds/"; my $themedir = "$GNUstep/Library/WindowMaker/Themes/"; my $bgfile = "$GNUstep/bg.txt"; my $themefile = "$GNUstep/themes.txt"; # # Add path to the wmsetbg and setstyle commands if necessary # my $bgcmd = "wmsetbg --tile"; my $themecmd = "setstyle"; my @rotate = &init; $SIG{CHLD} = 'IGNORE'; # Get rid of Zombie problems $SIG{USR1} = 'rotate'; # rotate whenever you want $SIG{QUIT} = 'quit'; $SIG{TERM} = 'quit'; Proc::Daemon::Init; # Run as Daemon my $PID = "$GNUstep/rotatebg.pid"; open PID,">$PID" or die ( $! ); print PID $$; close PID; while ( 1 ) { &rotate; } sub rotate { tie my @lines, 'Tie::File', $rotate[0] or die( $! ); # # uses the 1st file in the list, removes, sticks it on the bottom # so it rotates without repeat until it's finished the list. # my $file = $lines[0]; shift @lines; push @lines,$file; print qx( $rotate[2] $rotate[1]$file ); untie @lines; sleep $rotatetime; } sub init { # # don't rotate backgrounds if there's a theme file # if ( -f $bgfile && ! -z $bgfile && ! -f $themefile ) { return ( $bgfile, $bgdir, $bgcmd ); } elsif ( -f $themefile && ! -z $themefile ) { return ( $themefile, $themedir, $themecmd ); } else { die "Neither $bgfile nor $themefile exists\n: $!"; } } sub quit { unlink $PID; exit; }

--
"I just read perlman:perlboot," said Tom, objectively.
naChoZ

UPDATE: added theme support


In reply to Window Maker background/theme rotator by naChoZ

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.