-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-background-xml
More file actions
executable file
·71 lines (56 loc) · 1.62 KB
/
create-background-xml
File metadata and controls
executable file
·71 lines (56 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
function element()
{
echo "${1}<${2}>${3}</${2}>"
}
function starttime()
{
starttime=`date --utc +%Y\ %m\ %d\ %H\ %M\ %S`
echo " <starttime>"
element " " year `cut --delimiter=\ --fields=1 <<< ${starttime}`
element " " month `cut --delimiter=\ --fields=2 <<< ${starttime}`
element " " day `cut --delimiter=\ --fields=3 <<< ${starttime}`
element " " hour `cut --delimiter=\ --fields=4 <<< ${starttime}`
element " " minute `cut --delimiter=\ --fields=5 <<< ${starttime}`
element " " second `cut --delimiter=\ --fields=6 <<< ${starttime}`
echo " </starttime>"
}
function static()
{
echo " <static>"
element " " duration ${1}
element " " file "${2}"
echo " </static>"
}
function transition()
{
echo " <transition>"
element " " duration ${1}
element " " from "${2}"
element " " to "${3}"
echo " </transition>"
}
staticDuration=${1:-290}
transitionDuration=${2:-10}
temporaryFile=`mktemp`
find . -type f \( -iname *.gif -o -iname *.jp*g -o -iname *.png \) | cut --characters=2- | sort > ${temporaryFile}
readarray -t backgrounds < ${temporaryFile}
rm --force ${temporaryFile}
backgroundsSize=${#backgrounds[*]}
echo "<background>"
starttime
for ((fromIndex = 0 ; ${fromIndex} < ${backgroundsSize} ; fromIndex++))
do
toIndex=$((${fromIndex} + 1))
from="${PWD}${backgrounds[${fromIndex}]}"
if [ ${toIndex} -gt ${backgroundsSize} ]
then
to="${PWD}${backgrounds[0]}"
else
to="${PWD}${backgrounds[${toIndex}]}"
fi
static ${staticDuration} "${from}"
transition ${transitionDuration} "${from}" "${to}"
done
echo "</background>"
exit 0