UBUNTU動態案頭牆紙設定檔指令碼,配置步驟

來源:互聯網
上載者:User

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

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.