0

I have searched google high and low for a solution and had it working for a time, even added a whole slew of files to /usr/share/backgrounds (jpg, png, webp) and updated the /usr/share/gnome-background-properties/backgrounds.xml file to include the newly added files.

All worked fine. every image displayed in the background selector dialogue and on the desktop and the provided slideshows (like precise.xml) worked, too.

OK, cool. Then, I created my own slideshow xml file, and added it to the wallpapers in /usr/share/backgrounds/. and it worked great! but, the timing was not to my liking.

Originally, the duration was set to 300 seconds (five minutes) and the transition set to 5 seconds. nice, but I wanted to make some minor adjustments. so i did that using a perl script I wrote (output of which is below and truncated), and now...nothing works!

I am quite certain I have this setup correctly, but just can't figure out why it won't work.

here's my backgrounds.xml (stored in /usr/share/gnome-background-properties/)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE wallpapers SYSTEM "gnome-wp-list.dtd">
<wallpapers>
  <wallpaper deleted="false">
    <name>Slideshow</name>
    <filename>/usr/share/backgrounds/slideshow.xml</filename>
    <options>zoom</options>
  </wallpaper>
  <wallpaper>
    <_name>OK1</_name>
    <filename>/usr/share/backgrounds/OK1.jpg</filename>
    <options>zoom</options>
    <pcolor>#000000</pcolor>
    <scolor>#000000</scolor>
    <shade_type>solid</shade_type>
  </wallpaper>
  <wallpaper>
    <_name>OK10</_name>
    <filename>/usr/share/backgrounds/OK10.jpg</filename>
    <options>zoom</options>
    <pcolor>#000000</pcolor>
    <scolor>#000000</scolor>
    <shade_type>solid</shade_type>
  </wallpaper>
  <wallpaper>
    <_name>OK100</_name>
    <filename>/usr/share/backgrounds/OK100.jpg</filename>
    <options>zoom</options>
    <pcolor>#000000</pcolor>
    <scolor>#000000</scolor>
    <shade_type>solid</shade_type>
  </wallpaper>
  .
  .
  .
</wallpapers>

and my slideshow.xml (stored in /usr/share/backgrounds/)

<background>
  <starttime>
    <year>2009</year>
    <month>08</month>
    <day>04</day>
    <hour>00</hour>
    <minute>00</minute>
    <second>00</second>
  </starttime>
  <static>
    <duration>10.0</duration>
    <file>/usr/share/backgrounds/OK114.jpg</file>
  </static>
  <transition>
    <duration>3</duration>
    <from>/usr/share/backgrounds/OK114.jpg</from>
    <to>/usr/share/backgrounds/OK165.jpg</to>
  </transition>
  <static>
    <duration>10.0</duration>
    <file>/usr/share/backgrounds/OK165.jpg</file>
  </static>
  <transition>
    <duration>3</duration>
    <from>/usr/share/backgrounds/OK165.jpg</from>
    <to>/usr/share/backgrounds/OK209.jpg</to>
  </transition>
  <static>
    <duration>10.0</duration>
    <file>/usr/share/backgrounds/OK209.jpg</file>
  </static>
  <transition>
    <duration>3</duration>
    <from>/usr/share/backgrounds/OK209.jpg</from>
    <to>/usr/share/backgrounds/OK42.jpg</to>
  </transition>
  .
  .
  .
</background>

both of these xml files are huge. 2000+ lines.

this is baffling the jeepers out of me. when I bring up the background pictures selection dialogue, I can see my slideshow listed, and it even shows a randomly chosen image. but, when i double click it to be the background, my destkop wallpaper remains all black.

did I make a typo I'm not seeing? am I missing a critical detail? just lost on it.

any help is appreciated, and if I have forgotten to add something in, instead of berating me, and chasing me for not including it, simply ask for it, and I will happily include it.

I have searched lots of things. followed directions at the following sites (but not limited to): https://help.ubuntu.com/community/SlideshowWallpapers https://opensource.com/article/17/12/create-your-own-wallpaper-slideshow-gnome

now, I only see two images in the background selection dialogue. my slideshow file, and one image when there should be the slideshow, and so very many other images.

  • Hi, Can you just keep only 3 files 1 with .jpg 1 with .png and 1 with .webp and test it. how did you create slideshow.xml file? can you share that script? – PRATAP Nov 7 at 5:10
  • I have checked with around 500 images .jpg only with a script.. It respected the duration time I have given in seconds.. Ubuntu 19.10.. I think you are using 18.04? – PRATAP Nov 7 at 5:21
0

correct. 18.04. seems a simple reboot corrected the problem, because now it works! also, just learned i can restart the gnome desktop by pressing ALT-F2, type R, and press Enter. but, to honor the request to see the script which generates my slideshow:

#!/usr/bin/perl

use strict;
use Term::ReadKey; ReadMode 4;
use Term::ANSIColor;
use List::Util 'shuffle';

use lib "/var/www/html/Pm";
use Bc_dir qw(external_files write_text read_text);
use Bc_misc qw(shorten_str);

my ($wchar, $hchar, $wpixels, $hpixels) = GetTerminalSize();

my $clear = `clear`;

my $CURRENTDIR = "/usr/share/backgrounds";
my $FILE = "$CURRENTDIR/slideshow.xml";
my $MAX_DURATION = 3600; # maximum display time
my $MIN_DURATION = 10; # minimum display time
my $DURATION = 300.0; # actual display time
my $MAX_TRANSITION = 8.0; # maximum transition time
my $MIN_TRANSITION = 0.25; # minimum transition time
my $TRANSITION = 3.0; # actual transition time
my $DURATION_STEP = 10; # add/minus 10 seconds to/from duration time
my $TRANSITION_STEP = 0.25; # add/minus 0.25 seconds to/from transition time

my $TRANSITION_XML = <<END;
  <static>
    <duration>$DURATION</duration>
    <file>[thisfile]</file>
  </static>
  <transition>
    <duration>$TRANSITION</duration>
    <from>[thisfile]</from>
    <to>[nextfile]</to>
  </transition>
END

my @IMGS = external_files($CURRENTDIR, "jpg");
push @IMGS, external_files($CURRENTDIR, "jpeg");
push @IMGS, external_files($CURRENTDIR, "png");
push @IMGS, external_files($CURRENTDIR, "gif");

{
  my @new;
  foreach my $img (@IMGS) {
    if ($img) { push @new, $img; }
  }
  @IMGS = @new;
}

@IMGS = shuffle(@IMGS);

my $slideshow = "<background>\n";
$slideshow .= <<END;
  <starttime>
    <year>2009</year>
    <month>08</month>
    <day>04</day>
    <hour>00</hour>
    <minute>00</minute>
    <second>00</second>
  </starttime>
END

my $i = 0;
my $line = 0;
foreach my $file (@IMGS) {
  my $thisone = $TRANSITION_XML;
  $thisone =~ s/\[thisfile\]/$CURRENTDIR\/$file/g;

  my $nextfile = "";
  if ($line + $i + 1 < @IMGS)
    { $nextfile = $IMGS[$line + $i + 1]; } else
    { $nextfile = $IMGS[0]; }

  $thisone =~ s/\[nextfile\]/$CURRENTDIR\/$nextfile/g;
  $slideshow .= $thisone;
  $i++;
}

$slideshow .= "</background>\n";

sub hideCursor() { print "\e[?25l"; }
sub showCursor() { print "\e[0H\e[0J\e[?25h"; }

sub txt($;$) {
  my ($txt, $clr) = @_;
  my $rv = "";
  if ($txt) {
    if ($clr) { $rv = color($clr); }
    $rv .= $txt;
    if ($clr) { $rv .= color("reset"); }
  }

  return $rv;
}

sub error($) {
  my ($txt) = @_;
  my $rv = "";
  if ($txt) {
    $rv = color("bold red");
    $rv .= $txt;
    $rv .= color("reset");
  }

  return $rv;
}

sub notice($) {
  my ($txt) = @_;
  my $rv = "";
  if ($txt) {
    $rv = color("bold green");
    $rv .= $txt;
    $rv .= color("reset");
  }

  return $rv;
}

sub warning($) {
  my ($txt) = @_;
  my $rv = "";
  if ($txt) {
    $rv = color("bold yellow");
    $rv .= $txt;
    $rv .= color("reset");
  }

  return $rv;
}

sub end() {
  ReadMode 0;
  print warning("Peace out!\n\n");
  exit 1;
}

my $kbkey = 0;
sub getKeypress() {
  my $rv = undef;
  if (defined($kbkey = ReadKey(-1))) {
    $rv = $kbkey;
  }

  return $rv;
}

sub beep() {
  print chr(7);
}

sub show() {
  hideCursor();
  my $lines = 40;
  my $linelen = $wchar;
  my $page = 0;
  my $line = 0;
  my @slide = split("\n", $slideshow);
  my $displayed = 0;

  my $stop = 0;
  while (not $stop) {
    # display $lines lines, and ask for keypress
    if (not $displayed) {
      print $clear;

      for (my $i = 0; $i < $lines; $i++) {
        my $thisline = "";
        if ($slide[$line + $i]) {
          my $output = shorten_str($line + $i . ": " . $slide[$line + $i], $linelen) . "\n";
          print $output;
        }
      }

      print "\n";
      print warning("note: long lines are truncated to a maximum length of $linelen chars in this display!\n");
      print "press \n";
      print "  " . warning("N") . " for next page\n";
      print "  " . warning("P") . " for previous page\n";
      print "  " . warning("H") . " to jump to first page\n";
      print "  " . warning("E") . " to jump to last page\n";
      print "  " . warning("Q") . " to return to main menu\n";

      $displayed = 1;
    }

    my $key = getKeypress();
    if ($key) {
      lc $key;
      if ($key eq "q") {
        $stop = 1;
      } elsif ($key eq "n") {
        $line += $lines;
        if ($line > @slide - ($lines)) { $line = @slide - ($lines); }
        $displayed = 0;
      } elsif ($key eq "p") {
        $line -= $lines;
        if ($line < 0) { $line = 0; }
        $displayed = 0;
      } elsif ($key eq "h") {
        $line = 0;
        $displayed = 0;
      } elsif ($key eq "e") {
        $line = @slide - $lines;
        $displayed = 0;
      }
    }
  }

  showCursor();
}

sub writefile() {
  write_text($FILE, $slideshow);
}

sub showmenu(;$) {
  my ($msg) = @_;

  print $clear;

  if (ref $msg eq "HASH") {
    if ($msg->{warning})
      { print warning($msg->{warning} . "\n\n"); }
  } elsif ($msg) {
    print txt($msg) . "\n\n";
  }

  print "press\n";
  print "   " . warning("S") . " to display the slideshow data\n";
  print "   " . warning("W") . " to write the slideshow data to " . txt($FILE, "bold white") . "\n";
  print "   " . warning("L") . " to load the slideshow data from " . txt($FILE, "bold white") . "\n";
  print "   " . warning("+") . " to increase display DURATION of each image by 10 seconds\n";
  print "   " . warning("-") . " to decrease display DURATION of each image by 10 seconds\n";
  print "   " . warning("*") . " to increase TRANSITION time by 0.25 seconds\n";
  print "   " . warning("/") . " to decrease TRANSITION time by 0.25 seconds\n";
  print "\n   " . error("Q") . " to quit\n";
  print "\n";
  print "  Display Time: " . warning($DURATION) . "\n";
  print "  Transition Time: " . warning($TRANSITION) . "\n";
  print "\n";

  if (ref $msg eq "HASH") {
    if ($msg->{error})
      { print error($msg->{error} . "\n"); }
  }

  print "Selection: ";
}

sub initSlideshow() {
  $TRANSITION_XML = <<END;
  <static>
    <duration>$DURATION.0</duration>
    <file>[thisfile]</file>
  </static>
  <transition>
    <duration>$TRANSITION</duration>
    <from>[thisfile]</from>
    <to>[nextfile]</to>
  </transition>
END

  @IMGS = external_files($CURRENTDIR, "jpg");
  push @IMGS, external_files($CURRENTDIR, "jpeg");
  push @IMGS, external_files($CURRENTDIR, "png");
  push @IMGS, external_files($CURRENTDIR, "gif");

  {
    my @new;
    foreach my $img (@IMGS) {
      if ($img) { push @new, $img; }
    }
    @IMGS = @new;
  }

  @IMGS = shuffle(@IMGS);

  $slideshow = "<background>\n";
  $slideshow .= <<END;
  <starttime>
    <year>2009</year>
    <month>08</month>
    <day>04</day>
    <hour>00</hour>
    <minute>00</minute>
    <second>00</second>
  </starttime>
END

  my $i = 0;
  foreach my $file (@IMGS) {
    my $thisone = $TRANSITION_XML;
    $thisone =~ s/\[thisfile\]/$CURRENTDIR\/$file/g;

    my $nextfile = "";
    if ($line + $i + 1 < @IMGS)
      { $nextfile = $IMGS[$line + $i + 1]; } else
      { $nextfile = $IMGS[0]; }

    $thisone =~ s/\[nextfile\]/$CURRENTDIR\/$nextfile/g;
    $slideshow .= $thisone;
    $i++;
  }

  $slideshow .= "</background>\n";
}

sub load() {
  $slideshow = read_text($FILE);
}

my $stop = 0;
showmenu();

while (not $stop) {
  my $keypressed = getKeypress();
  if ($keypressed) {
    lc $keypressed;
    if ($keypressed eq "q") {
      print error("Q\n\n");
      $stop = 1;
    } elsif ($keypressed eq "w") {
      print warning("W\n\n");
      writefile();
      my %msg;
      $msg{warning} = "Slideshow Data Written to $FILE";
      showmenu(\%msg);
    } elsif ($keypressed eq "s") {
      print warning("S\n\n");
      show();
      showmenu();
    } elsif ($keypressed eq "l") {
      print warning("L\n\n");
      load();
      my %msg;
      $msg{warning} = "Slideshow Data Read from $FILE";
      showmenu(\%msg);
    } elsif ($keypressed eq "+") {
      print warning("+\n\n");
      $DURATION += $DURATION_STEP;
      if ($DURATION > $MAX_DURATION) { $DURATION = $MAX_DURATION; }
      initSlideshow();
      showmenu();
    } elsif ($keypressed eq "-") {
      print warning("-\n\n");
      $DURATION -= $DURATION_STEP;
      if ($DURATION < $MIN_DURATION) { $DURATION = $MIN_DURATION; }
      initSlideshow();
      showmenu();
    } elsif ($keypressed eq "*") {
      print warning("*\n\n");
      $TRANSITION += $TRANSITION_STEP;
      if ($TRANSITION > $MAX_TRANSITION) { $TRANSITION = $MAX_TRANSITION; }
      initSlideshow();
      showmenu();
    } elsif ($keypressed eq "/") {
      print warning("/\n\n");
      $TRANSITION -= $TRANSITION_STEP;
      if ($TRANSITION < $MIN_TRANSITION) { $TRANSITION = $MIN_TRANSITION; }
      initSlideshow();
      showmenu();
    } else {
      beep();
      showmenu({error=>"invalid key"});
    }
  }
}

end();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.