forked from aetherical/ignite-karaoke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
refill.sh
executable file
·56 lines (47 loc) · 1.19 KB
/
refill.sh
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
#!/bin/bash
set -eu
set -o pipefail
SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")"
SCRIPT_DIR=$(dirname ${SCRIPT_PATH})
SLIDES=${1:-20}
cd $SCRIPT_DIR
# [
# "index.md",
# {
# "filename": "slide-title.md",
# "attr": {
# "data-background": "#ff0000"
# }
# }
# ]
cat > /tmp/$$ <<EOF
[
{
"filename": "index.md",
"attr":
{
"data-autoslide": 5000,
"data-background-image": "resources/images/malte-wingen-J6fmT2TosSA-unsplash.jpg"
}
},
EOF
i=1
for file in $(find resources/images/ignite -type f | shuf -n ${SLIDES} --random-source /dev/random)
do
if [[ ! -e slides/${i}.html ]]; then
echo "" > slides/${i}.html
fi
echo " {" >> /tmp/$$
echo " \"filename\": \"${i}.html\"," >> /tmp/$$
echo " \"attr\": {" >> /tmp/$$
echo " \"data-background-image\": \"${file}\"," >> /tmp/$$
echo " \"data-background-size\": \"contain\"" >> /tmp/$$
echo " }" >> /tmp/$$
echo -n " }" >> /tmp/$$
i=$((i + 1))
if [[ $i -le ${SLIDES} ]]; then
echo "," >> /tmp/$$
fi
done
echo "]" >> /tmp/$$
mv /tmp/$$ slides/list.json