Skip to content

Instantly share code, notes, and snippets.

@ion1
Created March 25, 2010 23:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ion1/344247 to your computer and use it in GitHub Desktop.
Save ion1/344247 to your computer and use it in GitHub Desktop.
background-slideshow-generate
#!/bin/sh
set -e
duration=1800
dir="$(dirname "$0")"
dir="$(readlink -f "$dir")"
output="$dir/background.xml"
output_temp="$output.new$$"
trap 'rm -f "$output_temp"' 0 1 2 13 15
(
cat <<E
<background>
<starttime>
<year>2010</year><month>01</month><day>01</day>
<hour>00</hour><minute>00</minute><second>00</second>
</starttime>
E
find -L "$dir" -type f | \
shuf | \
file --mime-type -LNf - | \
sed -nr -e 's|(.*): image/[^ ]+$|\1|p' | \
while read f; do
printf ' <static><duration>%s</duration><file>%s</file></static>\n' \
"$duration" "$f"
done
cat <<E
</background>
E
) >"$output_temp"
mv -f "$output_temp" "$output"
# vim:set et sw=2 sts=2:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment