您的位置:首页 > 其它

UBUNTU动态桌面墙纸配置文件脚本,配置步骤

2013-05-20 17:40 351 查看
#!/bin/bash

xmlname="background-0.xml"

if [ $# -lt 3 ];then

echo -e "\033[1;33m--------------------------------------------------------------------------------\033[0m"

cat <<EOF

Decripition:

This tool lists all files in 'pictures-dir' and generate a background anmation script file.

If you created a script file, you can use it by:

(a) Right clicked on desktop

(b) Click 'Add...'

(c) Select 'All files' in 'file type selecter' which is in right-bottom corner

(d) Select this script file

(e) Enjoy it!

Usage:

bkground-list-gen.sh pictures-dir duration-secs change-secs

Remark:

All files, whose name includes space characters, is excluded in script file

EOF

echo -e "\033[1;33m--------------------------------------------------------------------------------\033[0m"

exit 0

fi

jpgDirectory=$1

secsDuration=$2

secsChanging=$3

if [ ! -d $jpgDirectory ];then

echo -e "\033[1;33m--------------------------------------------------------------------------------\033[0m"

echo "error: $jpgDirectory is not a dir!"

echo -e "\033[1;33m--------------------------------------------------------------------------------\033[0m"

exit 0

fi

# xmlname=${jpgDirectory}${xmlname}

if [ -f $xmlname ];then

rm $xmlname

if [ ! $? -eq 0 ]; then

echo -e "\033[1;33m--------------------------------------------------------------------------------\033[0m"

echo "error: $xmlname cant romove!"

echo -e "\033[1;33m--------------------------------------------------------------------------------\033[0m"

exit 0

fi

fi

echo "<background>" >> $xmlname

echo " <starttime>" >> $xmlname

echo " <year>2009</year>" >> $xmlname

echo " <month>08</month>" >> $xmlname

echo " <day>04</day>" >> $xmlname

echo " <hour>00</hour>" >> $xmlname

echo " <minute>00</minute>" >> $xmlname

echo " <second>00</second>" >> $xmlname

echo " </starttime>" >> $xmlname

echo "<!-- This animation will start at midnight. -->" >> $xmlname

count=0

filename=""

IFS_BACKUP=$IFS

IFS=$(echo -en "\n\b")

for file in `ls ${jpgDirectory}*.jpg`; do

filename=${file}

szfilt=$(echo "${filename}" | sed -r "s/jpg//g");

if [ ! x"${szfilt}" = x"${filename}" ]; then

count=`expr $count + 1`

if [ ! $count -eq 1 ];then

echo " <to>${filename}</to>" >> $xmlname;

echo " </transition>" >> $xmlname;

fi

echo " <static>" >> $xmlname;

echo " <duration>${secsDuration}</duration>" >> $xmlname;

echo " <file>${filename}</file>" >> $xmlname;

echo " </static>" >> $xmlname;

echo " <transition>" >> $xmlname;

echo " <duration>${secsChanging}</duration>" >> $xmlname;

echo " <from>${filename}</from>" >> $xmlname

echo "$count ${filename} done"

fi

done

IFS=$IFS_BACKUP

echo " </transition>" >> $xmlname

echo "</background>" >> $xmlname

echo -e "\033[1;33m--------------------------------------------------------------------------------\033[0m"

echo "xml file make done"

echo -e "\033[1;33m--------------------------------------------------------------------------------\033[0m"

# -------------------------------------------------------------------------------

# refers to http://blog.sina.com.cn/s/blog_702c2db50100pkcv.html
# -------------------------------------------------------------------------------
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: