-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDynamicDesktop.sh
More file actions
executable file
·125 lines (113 loc) · 2.42 KB
/
DynamicDesktop.sh
File metadata and controls
executable file
·125 lines (113 loc) · 2.42 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/bash
#date & time:02/05/13 19:48
#Author:sunheehnus
#Description:
# DynamicDesktop.sh /home/sunheehnus/Slam\ Dunk 60
#Version:1.0
if [ $# -ne 2 ]
then
echo "Please input enough paras!"
exit 1
fi
if [ ! -d "$1" ]
then
echo "Your target folder is not a pic folder!"
exit 2
fi
declare -i picnum=0
declare -a picnames
if ls "${1}/"*.jpg &>/dev/null
then
for pic in "${1}/"*.jpg
do
picnames["$picnum"]="$pic"
let 'picnum = picnum + 1'
done
fi
if ls "${1}/"*.jpeg &>/dev/null
then
for pic in "${1}/"*.jpeg
do
picnames["$picnum"]="$pic"
let 'picnum = picnum + 1'
done
fi
if [ $picnum -eq 0 ]
then
echo "There are no available(*.jpg *.jpeg) pictures in your target folder!"
exit 3
fi
interval_tmp=$(echo $2 | grep '[^[:digit:]]')
if [ -n "$interval_tmp" ]
then
echo "Your time interval is not a number!"
exit 4
fi
declare -i interval=$2
if [ $interval -lt "60" ]
then
echo "Your time interval is too short!"
exit 5
fi
declare -i interval_1="$interval-5"
declare -i interval_2="5"
prefix_name="/usr/share/backgrounds/"
name="bg"
cnt=0
while [ -d "${prefix_name}""${name}""${cnt}" ]
do
let "cnt = cnt + 1"
done
dirname="${prefix_name}""${name}""${cnt}"
mkdir "$dirname"
cat > "$dirname""/default.xml" << EOF
<background>
<starttime>
<year>2009</year>
<month>08</month>
<day>04</day>
<hour>00</hour>
<minute>00</minute>
<second>00</second>
</starttime>
<!-- This animation will start at midnight. -->
EOF
for i in $(seq 1 $(echo ${picnum}-1|bc))
do
now=$(echo ${i}-1|bc)
next=$i
cat >> "$dirname""/default.xml" << EOF
<static>
<duration>${interval_1}.0</duration>
<file>${picnames[$now]}</file>
</static>
<transition>
<duration>${interval_2}.0</duration>
<from>${picnames[$now]}</from>
<to>${picnames[$next]}</to>
</transition>
EOF
done
cat >> "$dirname""/default.xml" << EOF
<static>
<duration>${interval_1}.0</duration>
<file>${picnames[$i]}</file>
</static>
<transition>
<duration>${interval_2}.0</duration>
<from>${picnames[$i]}</from>
<to>${picnames[0]}</to>
</transition>
</background>
EOF
cat >/usr/share/gnome-background-properties/"${name}""${cnt}""-wallpapers"".xml" << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE wallpapers SYSTEM "gnome-wp-list.dtd">
<wallpapers>
<wallpaper deleted="false">
<name>Ubuntu 12.10 Community Wallpapers</name>
<filename>${dirname}/default.xml</filename>
<options>zoom</options>
</wallpaper>
</wallpapers>
EOF