2019独角兽企业重金招聘Python工程师标准>>>
#!/bin/bash
#
# 此脚本根据deepin-wallpaper-xml-generator改编而来。
# 用于生成Fedora15背景图片渐变文件,也可适用于Ubuntu。
# 该脚本未经严格测试,一切由它引发的悲剧,本人概不负责,请谨慎操作。
# 20110705 by junwuwei@gmail.com
################################################################################
#名称,可自定义
WALLPAPER_NAME="变形金刚渐变主题";
#图片目录,可自定义
WALLPAPER_DIR="/home/junwuwei/Pictures/backgrounds/变形金刚"
#渐变时间,渐变过程持续5秒。时间设置太短则看不到渐变效果。可自定义
DURATION_TIME="5.0"
#静态图片持续的时间。短一点可以很快看到效果。可自定义
STATIC_DURATION_TIME="5.0"
################################################################################
#系统目录,不建议更改
CONFIG_DIR="/usr/share/gnome-background-properties"
#生成图片渐变xml文件,不建议更改
XML_FILE="$WALLPAPER_DIR/$WALLPAPER_NAME-1.xml"
#生成图片渐变xml文件,不建议更改
XML_FILE_PROPERTIES="$CONFIG_DIR/$WALLPAPER_NAME.xml"#### First check if we have write permissions to the share dirctory. ####
touch $CONFIG_DIR/testfile >/dev/null 2>/dev/null
if [[ $? -ne 0 ]]; thenecho "**** 没有权限在 $CONFIG_DIR 目录下创建文件!****"exit 1
elserm $CONFIG_DIR/testfile 2>/dev/null
fi#### Show the script description message. ###
cat <
EOF#### Fail if the wallpaper directory does not exist. ####
if [[ ! -d $WALLPAPER_DIR ]]; thenecho "**** 目录 \"$WALLPAPER_DIR\" 不存在&#xff01;****"exit 1
fi#### Count the number of jpg/jpeg/png images. ####
numfiles&#61;&#96;ls -1 $WALLPAPER_DIR/*.jpg WALLPAPER_DIR/*.jpeg WALLPAPER_DIR/*.png 2>/dev/null | wc -l&#96;#### If there are no image files there then exit. ####
if [[ $numfiles -eq 0 ]]; thenecho "**** 目录 \"$WALLPAPER_DIR\" 下没有任何图片文件&#xff01; ****"exit 1
fi#### Now we create the XML file containing the images for backgrounds. ####
#### Start by creating the header in the XML file. ####
cat <
EOF
#### stretched zoom
cat <
EOF#### Add each file to the XML file. ####
#### Doing it this way makes sure files with spaces in their names are ####
#### handled properly. (ls .... | while read fname; do) ####
from_file&#61;
ls -1 $WALLPAPER_DIR/*.jpg $WALLPAPER_DIR/*.png $WALLPAPER_DIR/*.jpeg 2> /dev/null |
while read image_name; doecho $from_fileif [ -f "$from_file" ]; then echo " Adding: &#96;basename "$image_name"&#96;."echo "
echo "
cat <
################################################################################EOF