yep, that was the intended design. the scripts purpose is to randomly select a wallpaper and set it in gnome2. i can then add it to my startup scripts, and it'll change the wallpaper, either once at login, or continuously while i am logged in, depending upon what i've set $mode to.

i've modified it a bit more though, so maybe this makes more sense...
#!/usr/bin/perl use strict; use warnings; use XML::Simple; srand; # Mode to run my $mode = "startup"; # Interval to change at if we want $mode = "running" my $interval = $ARGV[0]; # Change the mode if we have been passed an interval $mode = "running" if ($interval); # gconf vars my $command = "gconftool-2"; my $gconf_item = "/desktop/gnome/background/picture_filename"; # The location of the background xml file my $xmlfile = $ENV{HOME} . "/.gnome2/backgrounds.xml"; # Die if we dont have a background xml file die("No backgrounds file [$xmlfile] found!") if (! -e $xmlfile); # Find the current background so we dont change to this my $current = `$command -g $gconf_item`; # Read in the xml file contents to get our list of backgrounds my $config = XMLin($xmlfile); # Something to store our filenames in my @backs; foreach my $name (keys %{$config->{wallpaper}}) { # Skip any that have a deleted flag in the XML file next if ($config->{wallpaper}->{$name}->{deleted} eq "true"); # Set the filename my $file = $config->{wallpaper}->{$name}->{filename}; # Ignore the current background and the (none) background next if (($file eq $current) || ($file eq "(none)")); # Store the name in our array push(@backs, $file); } # end-foreach while (1) { # Get a random background from the array my $new = $backs[int(rand(@backs))]; # Set the background to something new system($command . ' --type=string -s '. $gconf_item . ' \'' . $new . + '\''); # Break out of our while loop if mode ne "running" last if ($mode ne "running"); # Sleep for some time sleep($interval*60); } # end-while exit;

In reply to Re^4: how to loop by rsiedl
in thread how to loop by rsiedl

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.