Skip to content

Instantly share code, notes, and snippets.

@sbliven sbliven/test10.sh
Created Feb 6, 2019

Embed
What would you like to do?
Generate evenly-spaced heic file for testing Mac dynamic wallpapers
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
JSONFILE="${1:-wallpapper.json}"
HEICFILE="${2:-wallpapper.heic}"
blocks=()
for ((a=-90;a<=90;a+=10)); do
for ((z=0; z<360; z+=10)); do
f="test_${a}_${z}.png"
# Create image
convert -background lightblue -fill blue \
-pointsize 128 -font "Chalkduster" \
-size 2880x1800 -gravity center \
label:"Elevation:$a\nAzimuth:$z" "$f"
if [[ a == 0 && z == 0 ]]; then
primary=true
else
primary=false
fi
if [[ a < 0 ]]; then
isForLight=true
isForDark=false
else
isForLight=false
isForDark=true
fi
IFS='' read -r -d '' BLOCK <<END || true
{
"fileName": "$f",
"isPrimary": $primary,
"isForLight": $isForLight,
"isForDark": $isForDark,
"altitude": $a,
"azimuth": $z
}
END
blocks+=("$BLOCK")
done
done
{
echo "["
echo -n "${blocks[0]}"
for ((i=1;i<"${#blocks[@]}";i++)); do
echo -n ",${blocks[$i]}"
done
echo "]"
} > "$JSONFILE"
/usr/local/bin/wallpapper -i "$JSONFILE" -o "$HEICFILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.