AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1186814
Accepted
Jarett Lloyd
Jarett Lloyd
Asked: 2019-11-07 14:18:51 +0800 CST2019-11-07 14:18:51 +0800 CST 2019-11-07 14:18:51 +0800 CST

xml 幻灯片无法像墙纸那样正常工作

  • 772

我已经在谷歌上下搜索了一个解决方案并让它工作了一段时间,甚至添加了一大堆文件/usr/share/backgrounds(jpg、png、webp)并更新了/usr/share/gnome-background-properties/backgrounds.xml文件以包含新添加的文件。

一切正常。背景选择器对话框和桌面上显示的每个图像以及提供的幻灯片(如precision.xml)也都有效。

嗯不错。然后,我创建了自己的幻灯片 xml 文件,并将其添加到/usr/share/backgrounds/. 效果很好!但是,时机不符合我的喜好。

最初,持续时间设置为 300 秒(五分钟),转换设置为 5 秒。很好,但我想做一些小的调整。所以我使用我编写的 perl 脚本来做到这一点(其输出在下方并被截断),现在......没有任何效果!

我很确定我的设置正确,但就是不知道为什么它不起作用。

这是我的backgrounds.xml(存储在/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>

和我的slideshow.xml(存储在/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>

这两个 xml 文件都很大。2000+ 行。

这让我很困惑。当我调出背景图片选择对话框时,我可以看到我的幻灯片列出了,它甚至显示了一个随机选择的图像。但是,当我双击它作为背景时,我的 destkop 壁纸仍然是全黑的。

我是否打错了我没有看到的错字?我错过了一个关键细节吗?只是迷路了。

感谢您提供任何帮助,如果我忘记添加某些内容,而不是责备我,并追逐我没有包含它,只需请求它,我会很乐意包含它。

我已经搜索了很多东西。遵循以下站点的指示(但不限于): https ://help.ubuntu.com/community/SlideshowWallpapers https://opensource.com/article/17/12/create-your-own-wallpaper-slideshow-侏儒

现在,我在背景选择对话框中只看到两个图像。我的幻灯片文件,还有一张应该有幻灯片的图像,还有很多其他的图像。

gnome wallpaper slideshow
  • 1 1 个回答
  • 1269 Views

1 个回答

  • Voted
  1. Best Answer
    Jarett Lloyd
    2019-11-09T15:09:46+08:002019-11-09T15:09:46+08:00

    正确的。18.04。似乎一个简单的重启就解决了这个问题,因为现在它可以工作了!另外,刚刚得知我可以通过按 重新启动 gnome 桌面ALT-F2, type R, and press Enter。但是,为了尊重查看生成我的幻灯片的脚本的请求:

    #!/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();
    
    • 0

相关问题

  • 停止菜单图标闪烁

  • 是否有适用于 IMAP 邮件帐户的 Gnome 小程序?

  • 如何创建桌面墙纸幻灯片?

  • 如何提交壁纸以考虑包含在 Ubuntu 中?

  • 如果顶部面板中缺少会话小程序,如何注销?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve