Skip to content

Instantly share code, notes, and snippets.

@JrCs
Last active August 29, 2015 14:07
Show Gist options
  • Save JrCs/811ffbc0f36ccf6d77cb to your computer and use it in GitHub Desktop.
Save JrCs/811ffbc0f36ccf6d77cb to your computer and use it in GitHub Desktop.
Get Clover theme.plist from git repository
#!/bin/bash
export_dir="/tmp/foo"
mkdir -p $export_dir
tmp_dir=$(mktemp -d -t theme_manager)
declare -a urls=(
'https://bitbucket.org/blackosx/black_green' \
'https://bitbucket.org/blackosx/bgm256' \
'https://bitbucket.org/blackosx/shield' \
'https://bitbucket.org/blackosx/bgm')
declare -a themes=()
function md5 {
md5sum "$1" | cut -d' ' -f1
}
echo "Getting themes.plist..."
index=0
while [[ "x${urls[index]}" != "x" ]]; do
url="${urls[index]}"
theme=${url##*/}
themes[index]="$theme"
mkdir -p "$tmp_dir/$theme"
curl --silent "$url/raw/HEAD/theme.plist" -o "$tmp_dir/$theme/theme.plist" &
(( index++ ))
done
# Wait for all the downloads to finish
wait
for theme in "${themes[@]}"; do
get_preview=0
if [[ ! -d "$export_dir/$theme" ]]; then
mv "$tmp_dir/$theme" "$export_dir/$theme"
get_preview=1
else
if [[ $(md5 "$tmp_dir/$theme/theme.plist") != $(md5 "$export_dir/$theme/theme.plist") ]]; then
cp "$tmp_dir/$theme/theme.plist" "$export_dir/$theme/theme.plist"
get_preview=1
fi
fi
if [[ "$get_preview" -eq 1 ]]; then
# Get the preview
curl --silent "$url/raw/HEAD/screenshot.png" -o "$export_dir/$theme/screenshot.png" &
fi
done
rm -rf "$tmp_dir"
# Wait for all the downloads to finish
wait
echo "Theme plist are in '$export_dir' directory."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment