ubuntu 动态桌面xml文件生成脚本
2010-09-22 17:09
351 查看
Ubuntu 动态桌面xml文件,生成脚本 (bash shell)
#!/bin/bash #!/bin/bash # ubuntu background.xml create # 2010.09 # v 0.1 create_head () { echo '<background>' >>$outfile echo '<starttime>' >>$outfile echo ' <year>2010</year>' >>$outfile echo '<month>09</month>' >>$outfile echo ' <day>00</day>' >>$outfile echo ' <hour>00</hour>' >>$outfile echo ' <minute>00</minute>' >>$outfile echo ' <second>00</second>' >>$outfile echo ' </starttime>' >>$outfile echo ' <!--++++-->' >>$outfile } first=1 file_first="" install_one () { file_one=$1 if [ $first -eq 0 ];then echo " <to>$file_one</to>" >>$outfile echo "</transition>" >>$outfile else first=0 file_first=$file_one fi echo "<static>" >>$outfile echo " <duration>$static</duration>" >>$outfile echo " <file>$file_one</file>" >>$outfile echo "</static>" >>$outfile echo "<transition>" >>$outfile echo " <duration>$delay</duration>" >>$outfile echo " <from>$file_one</from>" >>$outfile } isimage () { file $1 | grep image &> /dev/null && return 0 return 1 } dir () { c_dir=`pwd` cd $dir dir=`pwd` #echo $dir for file in `ls $dir` do isimage $file && install_one $dir/$file done cd $c_dir } configfile () { for file in `cat $configfile` do isimage $file && install_one $file done } # ============================ # usage ====================== # ============================ usage () { echo "Usage: -l , --delay delay time (s) ,default is 3 s" echo " -s , --static static time (s) ,default is 1800 s (30min)" echo " -d , --dir Use the specified folder to create config file" echo " for all files" echo " -c , --configfile Specify a configuration file,it's a list of files" } [ -z "$*" ] && { usage exit 2 } outfile=/tmp/background.outfile touch $outfile echo >$outfile delay=5 static=1800 while true do opt=`echo $* | cut -d' ' -f1` shift 1 val=`echo $* | cut -d' ' -f1` case $opt in -d|--dir) [ -d "$val" -a -z "$configfile" ] && dir=$val || { echo $opt Error exit 1 };; -l|--delay) [ -n "$val" ] && delay=$val || { echo $opt Error exit 1 };; -s|--static) [ -n "$val" ] && static=$val || { echo $opt Error exit 1 };; -c|--configfile) [ -f "$val" -a -z "$dir" ] && configfile=$val || { echo $opt Error exit 1 };; -h|--help) usage exit 1;; *) if [ -n "$opt" ];then echo invalib option:$opt echo "Try '`basename $0` -h/--help' for more information." fi break;; esac shift 1 done create_head if [ -n "$dir" ] ;then dir elif [ -n "$configfile" ] ;then configfile else echo `basename $0`: Must use the option -d / -c exit 2 fi echo " <to>$file_first</to>" >>$outfile echo "</transition>" >>$outfile echo '</background>' >>$outfile cat /tmp/background.outfile echo "" exit 0
脚本选项说明:
-l / --delay 两张壁纸切换的渐变时间,单位 秒, 默认3 秒
-s / --static 多长时间进行一次壁纸的切换,单位 秒 ,默认 1800 秒 /30 分钟
-d / --dir 指定一个目录,该目录下的所有图片文件,都将做为壁纸写入xml文件中
-c / --configfile 指定一个配置文件,该文件中含壁纸文件的完整路径,一行一个文件路径
补充说明:
1, -d 和-c选项不能同时使用
2, 。。。。。
相关文章推荐
- ubuntu / Mint下 perl 实现动态桌面壁纸 生成xml的实用脚本
- UBUNTU动态桌面墙纸配置文件脚本,配置步骤
- 利用TreeView控件动态生成无限级树(续:通过绑定动态xml文件)
- 通过C#动态生成图书信息XML文件
- 【转载】详解SQL2005/SQL2008动态生成分区脚本的方法
- Js - JQ事件委托( 适用于给动态生成的脚本元素添加事件)
- 写了一个脚本,生成gnome桌面背景slide模式所需的xml文件
- SQL Server 动态生成分区脚本
- 一个动态生成脚本的例子
- ORACLE动态完全数据日志(AUDIT LOG)批处理生成脚本
- Extjs4.0 开发笔记-desktop 桌面菜单动态生成
- 在ubuntu中cosmos动态壁纸的python实现脚本
- 生成ubuntu自动切换壁纸xml文件的php代码
- 利用TreeView控件动态生成无限级树(续:通过绑定动态xml文件)(转)
- 判断元素是否已经被js等动态脚本生成
- SQL Server分区动态生成脚本(三)(按年份划分)
- [转] ubuntu Linux/Mint 下实现动态桌面壁纸 de 原理
- [脚本]利用svn版本号动态生成version.h
- Razor Engine,动态脚本语言,mvc上的语法,适用于文件内容生成,静态网页生成等。