首页 > 技术文章 > Ubuntu自动壁纸

luomit 2020-11-06 19:57 原文

Ubuntu下批量壁纸自动更新的方法

要在ubuntu上实现壁纸的动态更换,首先要记住两个路径下的文件
/usr/share/backgrounds 这里是系统存放壁纸和壁纸动态更换脚本的地方,脚本在contest下,以.xml结尾的就是控制播放的脚本了;
/usr/share/gnome-background-properties 这里的.xml和/usr/share/backgrounds/contest/下的mxl不同;这里的.xml文件是实现壁纸在系统设置中呈现,并加载动态更换脚本的;
/usr/share/backgrounds/contest/groovy.xml文件原始内容如下(仅用做参考和备份),不对这个文件做修改

<background>
  <starttime>
    <year>2009</year>
    <month>08</month>
    <day>04</day>
    <hour>00</hour>
    <minute>00</minute>
    <second>00</second>
  </starttime>
<!-- This animation will start at midnight. -->
  <static>
    <duration>1795.0</duration>
    <file>/usr/share/backgrounds/Landscape_Photography_Of_Mountains_by_Simon_Berger.jpg</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/usr/share/backgrounds/Landscape_Photography_Of_Mountains_by_Simon_Berger.jpg</from>
    <to>/usr/share/backgrounds/Silver_Back_Gorilla_by_Mike_Arney.jpg</to>
  </transition>
  <static>
    <duration>1795.0</duration>
    <file>/usr/share/backgrounds/Silver_Back_Gorilla_by_Mike_Arney.jpg</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/usr/share/backgrounds/Silver_Back_Gorilla_by_Mike_Arney.jpg</from>
    <to>/usr/share/backgrounds/Camera_Film_by_Markus_Spiske.jpg</to>
  </transition>
  <static>
    <duration>1795.0</duration>
    <file>/usr/share/backgrounds/Camera_Film_by_Markus_Spiske.jpg</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/usr/share/backgrounds/Camera_Film_by_Markus_Spiske.jpg</from>
    <to>/usr/share/backgrounds/Colored_Pencils_by_Jess_Bailey.jpg</to>
  </transition>
  <static>
    <duration>1795.0</duration>
    <file>/usr/share/backgrounds/Colored_Pencils_by_Jess_Bailey.jpg</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/usr/share/backgrounds/Colored_Pencils_by_Jess_Bailey.jpg</from>
    <to>/usr/share/backgrounds/Abstract_Painting_Photo_by_Pierre_Châtel-Innocenti.jpg</to>
  </transition>
  <static>
    <duration>1795.0</duration>
    <file>/usr/share/backgrounds/Abstract_Painting_Photo_by_Pierre_Châtel-Innocenti.jpg</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/usr/share/backgrounds/Abstract_Painting_Photo_by_Pierre_Châtel-Innocenti.jpg</from>
    <to>/usr/share/backgrounds/Gorilla_Wallpaper_Grey_4096x2304.png</to>
  </transition>
  <static>
    <duration>1795.0</duration>
    <file>/usr/share/backgrounds/Gorilla_Wallpaper_Grey_4096x2304.png</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/usr/share/backgrounds/Gorilla_Wallpaper_Grey_4096x2304.png</from>
    <to>/usr/share/backgrounds/Landscape_Photography_Of_Mountains_by_Simon_Berger.jpg</to>
  </transition>
</background>

/usr/share/gnome-background-properties/groovy-wallpapers.xml文件原始内容如下(仅用做参考和备份),不对这个文件做修改

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE wallpapers SYSTEM "gnome-wp-list.dtd">
<wallpapers>
 <wallpaper deleted="false">
   <name>Ubuntu 20.10 Community Wallpapers</name>
   <filename>/usr/share/backgrounds/contest/groovy.xml</filename>
   <options>zoom</options>
 </wallpaper>
 <wallpaper>
     <name>Abstract Painting Photo</name>
     <filename>/usr/share/backgrounds/Abstract_Painting_Photo_by_Pierre_Châtel-Innocenti.jpg</filename>
     <options>zoom</options>
     <pcolor>#000000</pcolor>
     <scolor>#000000</scolor>
     <shade_type>solid</shade_type>
 </wallpaper>
 <wallpaper>
     <name>Camera Film</name>
     <filename>/usr/share/backgrounds/Camera_Film_by_Markus_Spiske.jpg</filename>
     <options>zoom</options>
     <pcolor>#000000</pcolor>
     <scolor>#000000</scolor>
     <shade_type>solid</shade_type>
 </wallpaper>
 <wallpaper>
     <name>Colored Pencils</name>
     <filename>/usr/share/backgrounds/Colored_Pencils_by_Jess_Bailey.jpg</filename>
     <options>zoom</options>
     <pcolor>#000000</pcolor>
     <scolor>#000000</scolor>
     <shade_type>solid</shade_type>
 </wallpaper>
 <wallpaper>
     <name>Landscape Photography Of Mountains</name>
     <filename>/usr/share/backgrounds/Landscape_Photography_Of_Mountains_by_Simon_Berger.jpg</filename>
     <options>zoom</options>
     <pcolor>#000000</pcolor>
     <scolor>#000000</scolor>
     <shade_type>solid</shade_type>
 </wallpaper>
 <wallpaper>
     <name>Silver Back Gorilla</name>
     <filename>/usr/share/backgrounds/Silver_Back_Gorilla_by_Mike_Arney.jpg</filename>
     <options>zoom</options>
     <pcolor>#000000</pcolor>
     <scolor>#000000</scolor>
     <shade_type>solid</shade_type>
 </wallpaper>
</wallpapers>

以上两个文件最好做下备份,然后将这两个文件的备份文件使用 方法禁用掉;这样在这两个文件上就可以自由修改了;

下载壁纸

直接贴大佬分享的帖子

推荐阅读