Gnome3桌面自动切换壁纸
- 编写控制文件mybackground.xml,使用shell脚本自动生成
#!/usr/bin/bash
# chgwallp.sh
# 生成xml控制文件
dir=/home/liangjin/Pictures/Background # 图片所在目录
dur=180.0
tra=3.0
file=`ls -u $dir | grep -v contest`
last_file='empty'
echo '<background>'
echo ' <starttime>'
echo ' <year>2018</year>'
echo ' <month>12</month>'
echo ' <day>9</day>'
echo ' <hour>8</hour>'
echo ' <minute>00</minute>'
echo ' <second>00</second>'
echo ' </starttime>'
echo ''
for current_file in $file
do
if [ "$last_file" = "empty" ]; then
last_file=$current_file
first_file=$last_file
echo '<static>'
echo '<duration>'$dur'</duration>'
echo "<file>$dir/$last_file</file>"
echo '</static>'
else
echo '<transition>'
echo '<duration>'$tra'</duration>'
echo "<from>$dir/$last_file</from>"
echo "<to>$dir/$current_file</to>"
echo '</transition>'
echo '<static>'
echo '<duration>'$dur'</duration>'
echo "<file>$dir/$current_file</file>"
echo '</static>'
last_file=$current_file
fi
done
echo '<transition>'
echo '<druation>'$tra'</duration>'
echo "<from>$dir/$last_file</from>"
echo "<to>$dir/$first_file</to>"
echo '</transition>'
echo '<background>'
执行
sh chgwallp.sh > mybackground.xml
- 复制到目录
sudo cp mybackground.xml /usr/share/backgrounds/
- 编写生效文件
/usr/share/gnome-background-properties/myback.xml
<?xml version="1.0"?>
<!DOCTYPE wallpapers SYSTEM "gnome-wp-list.dtd">
<wallpapers>
<wallpaper deleted="false">
<name>Wifes</name>
<filename>/usr/share/backgrounds/mybackground.xml</filename>
<options>zoom</options>
<shade_type>solid</shade_type>
<pcolor>#3465a4</pcolor>
<scolor>#000000</scolor>
</wallpaper>
</wallpapers>
- 打开设置,更换壁纸