ubuntu自動更換壁紙

創建一個.sh文件

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

path後面的地址爲你放圖片的文件夾的地址。需要根據情況更改。

#!/usr/bin/env bash
# AUTHOR:   eagle
# EMAIL:   [email protected]
# 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>標籤下名字相同的即可。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章