Last active
February 26, 2024 07:30
-
-
Save journey-ad/75005a787c2917564d069c7240516db0 to your computer and use it in GitHub Desktop.
生成壁纸列表xml并应用到系统,适用于gnome
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DIR1="`dirname $BASH_SOURCE`" | |
DIR=`readlink -f "$DIR1"` | |
files=$(find "$DIR" -maxdepth 3 -iregex ".*\.\(png\|jpg\|jpeg\|bmp\|gif\)$") | |
last_file="empty" | |
mode=${1:-zoom} | |
xml=${2:-"mylist.xml"} | |
static=${3:-600.0} | |
transition=${4:-5.0} | |
echo `date` | |
echo "Mode=$mode FileName=$xml Static=$static Transition=$transition" | |
echo "maxdepth=3" | |
echo "----------------------------------------------------------" | |
echo "$files" | |
echo "<background>" > $DIR/$xml | |
echo " <starttime>" >> $DIR/$xml | |
echo " <year>`date +%Y`</year>" >> $DIR/$xml | |
echo " <month>`date +%m`</month>" >> $DIR/$xml | |
echo " <day>`date +%d`</day>" >> $DIR/$xml | |
echo " <hour>`date +%H`</hour>" >> $DIR/$xml | |
echo " <minute>`date +%M`</minute>" >> $DIR/$xml | |
echo " <second>`date +%S`</second>" >> $DIR/$xml | |
echo " </starttime>" >> $DIR/$xml | |
echo "$files" | while read current_file | |
do | |
if [[($last_file == "empty")]] | |
then | |
last_file=$current_file | |
echo " <static>" >> $DIR/$xml | |
echo " <duration>$static</duration>" >> $DIR/$xml | |
echo " <file>$last_file</file>" >> $DIR/$xml | |
echo " </static>" >> $DIR/$xml | |
else | |
echo " <transition>" >> $DIR/$xml | |
echo " <duration>$transition</duration>" >> $DIR/$xml | |
echo " <from>$last_file</from>" >> $DIR/$xml | |
echo " <to>$current_file</to>" >> $DIR/$xml | |
echo " </transition>" >> $DIR/$xml | |
echo " <static>" >> $DIR/$xml | |
echo " <duration>$static</duration>" >> $DIR/$xml | |
echo " <file>$current_file</file>" >> $DIR/$xml | |
echo " </static>" >> $DIR/$xml | |
last_file=$current_file | |
fi | |
done | |
echo "</background>" >> $DIR/$xml | |
gsettings set org.gnome.desktop.background picture-uri "file://$DIR/$xml" | |
gsettings set org.gnome.desktop.background picture-options $mode | |
echo "----------------------------------------------------------" | |
echo "done" |
Author
journey-ad
commented
Nov 15, 2016
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment