為了開(kāi)發(fā)android 功能,ubuntu系統(tǒng)也使用了好久時(shí)間,作為一個(gè)經(jīng)常使用的系統(tǒng),不搗鼓搗鼓就太平淡,根據(jù)網(wǎng)上的一些介紹,搞了一個(gè)動(dòng)態(tài)壁紙出來(lái),用來(lái)定時(shí)更換壁紙。
首先創(chuàng)建一個(gè)文件夾,里面三個(gè)文件,其余根據(jù)自己喜好放入壁紙文件。

第一個(gè)文件addbackground.sh,需要可執(zhí)行權(quán)限
sudo rm -rf /usr/share/backgrounds/test
sudo mkdir /usr/share/backgrounds/test
sudo cp *.jpg /usr/share/backgrounds/test/
. makelist.sh > background.xml
sudo cp background.xml /usr/share/backgrounds/test/
sudo cp cust-wallpapers.xml /usr/share/gnome-background-properties/
gsettings set org.gnome.desktop.background picture-uri 'file:///usr/share/backgrounds/test/background.xml'
第二個(gè)文件,用于拷貝到gnome-background-properties,這樣設(shè)置里面就可以選擇作為動(dòng)態(tài)壁紙
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE wallpapers SYSTEM "gnome-wp-list.dtd">
<wallpapers>
<wallpaper deleted="false">
<name>wentao wallpaper</name>
<filename>/usr/share/backgrounds/test/background.xml</filename>
<options>zoom</options>
</wallpaper>
</wallpapers>
第三個(gè)文件makelist.sh 也需要可執(zhí)行權(quán)限
#!/bin/bash
# wentao add 2017.6.27
#get current path
basepath=$(cd `dirname $0`; pwd)
#get all jpg wallpapers
files=`ls $basepath |grep jpg`
lastfile='empty'
echo '<background>'
echo ' <starttime>'
echo ' <year>2017</year>'
echo ' <month>3</month>'
echo ' <day>15</day>'
echo ' <hour>00</hour>'
echo ' <minute>00</minute>'
echo ' <second>00</second>'
echo ' </starttime>'
for current_file in $files
do
if [[ $lastfile == 'empty' ]]
then
lastfile=$current_file
echo ' <static>'
echo ' <duration>300.0</duration>'
echo " <file>/usr/share/backgrounds/test/$lastfile</file>"
echo ' </static>'
else
echo ' <transition>'
echo ' <duration>5.0</duration>'
echo " <from>/usr/share/backgrounds/test/$lastfile</from>"
echo " <to>/usr/share/backgrounds/test/$current_file</to>"
echo ' </transition>'
echo ' <static>'
echo ' <duration>300.0</duration>'
echo " <file>/usr/share/backgrounds/test/$current_file</file>"
echo ' </static>'
lastfile=$current_file
fi
done
echo '</background>'
設(shè)置完成以后,運(yùn)行 ./addbackgroundd.sh,就可以設(shè)置動(dòng)態(tài)壁紙了,如果想更換動(dòng)態(tài)壁紙里的圖片,只要更新當(dāng)前文件夾里面的圖片就可以了。