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

#!/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

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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值