Skip to content

Commit

Permalink
DRY download script
Browse files Browse the repository at this point in the history
  • Loading branch information
saltedcoffii committed Apr 28, 2022
1 parent f52dbdf commit da2a9d8
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions download-backgrounds.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
#!/usr/bin/env bash
set -e

declare -A downloads=(
['https://512pixels.net/downloads/macos-wallpapers/11-0-Night.jpg']='bigsur-d.jpg'
['https://512pixels.net/downloads/macos-wallpapers/11-0-Day.jpg']='bigsur-l.jpg'
['https://512pixels.net/downloads/macos-wallpapers/11-0-Big-Sur-Color-Night.jpg']='bigsur-color-d.jpg'
['https://512pixels.net/downloads/macos-wallpapers/11-0-Color-Day.jpg']='bigsur-color-l.jpg'
['https://512pixels.net/downloads/macos-wallpapers/10-15-Night.jpg']='catalina-d.jpg'
['https://512pixels.net/downloads/macos-wallpapers/10-15-Day.jpg']='catalina-l.jpg'
['https://512pixels.net/downloads/macos-wallpapers-6k/10-14-Night-6k.jpg']='mojave-d.jpg'
['https://512pixels.net/downloads/macos-wallpapers-6k/10-14-Day-6k.jpg']='mojave-l.jpg'
['https://512pixels.net/downloads/macos-wallpapers-6k/12-Dark.jpg']='monterey-d.jpg'
['https://512pixels.net/downloads/macos-wallpapers-6k/12-Light.jpg']='monterey-l.jpg'
_baseurl="https://512pixels.net/downloads/macos-wallpapers"

declare -A downloads=(
["$_baseurl/11-0-Night.jpg"]="bigsur-d.jpg"
["$_baseurl/11-0-Day.jpg"]="bigsur-l.jpg"
["$_baseurl/11-0-Big-Sur-Color-Night.jpg"]="bigsur-color-d.jpg"
["$_baseurl/11-0-Color-Day.jpg"]="bigsur-color-l.jpg"
["$_baseurl/10-15-Night.jpg"]="catalina-d.jpg"
["$_baseurl/10-15-Day.jpg"]="catalina-l.jpg"
["$_baseurl-6k/10-14-Day-6k.jpg"]="mojave-l.jpg"
["$_baseurl-6k/10-14-Night-6k.jpg"]="mojave-d.jpg"
["$_baseurl-6k/12-Dark.jpg"]="monterey-d.jpg"
["$_baseurl-6k/12-Light.jpg"]="monterey-l.jpg"
)

for url in "${!downloads[@]}"; do
curl -L "${url}" -o $(dirname $0)/backgrounds/"${downloads[${url}]}";
curl -L "${url}" -o "$(dirname "$0")"/backgrounds/"${downloads[${url}]}";
done

0 comments on commit da2a9d8

Please sign in to comment.