ubuntu自动更换壁纸

创建一个.sh文件

eagle@eagle-com:~$ vim background.sh

path后面的地址为你放图片的文件夹的地址。需要根据情况更改。

#!/usr/bin/env bash
# AUTHOR:   eagle
# EMAIL:   bruce.e.zhao@gmail.com
# FILE:     my.sh
# ROLE:     TODO (some explanation)
# CREATED:  2016-10-18 19:27:58
# MODIFIED: 2016-10-18 21:45:23
path=/home/eagle/Pictures/background
files=`ls -U $path`
last_file='empty'

echo '<background>'
echo ' <starttime>'
echo '   <year>2009</year>'
echo '   <month>08</month>'
echo '   <day>04</day>'
echo '   <hour>00</hour>'
echo '   <minute>00</minute>'
echo '   <second>00</second>'
echo ' </starttime>'

for current_file in $files
do
	if [[ $last_file == 'empty' ]] 
	then
		last_file=$current_file
		echo ' <static>'
		echo '   <duration>295.0</duration>'
		echo "   <file>$path/$last_file</file>"
		echo ' </static>'
	else 
		echo ' <transition>'
		echo '    <duration>5.0</duration>'
		echo "    <from>$path/$last_file</from>"
		echo "    <to>$path/$current_file</to>"
		echo ' </transition>'
		echo ' <static>'
		echo '   <duration>295.0</duration>'
		echo "   <file>$path/$current_file</file>"
		echo ' </static>'
		last_file=$current_file 
	fi
done

echo '</background>'

eagle@eagle-com:~$ chmod 755 background.sh

eagle@eagle-com:~$ ./background.sh > mybackground.xml

eagle@eagle-com:~$ vim /usr/share/gnome-background-properties/xenial-wallpapers.xml



 <wallpaper deleted="false">
   <name>mybackground</name>
   <filename>/home/eagle/Pictures/mybackground.xml</filename>
   <options>zoom</options>
 </wallpaper>

即在该文件中添上上面5句话,<name>标签中可随意起一个名字。<filename>标签为xml文件的地址。


之后在背景里选择与<name>标签下名字相同的即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值