-
-
Save rk295/0ea95dec7d64eb8f0ed98fae3dadbdfc to your computer and use it in GitHub Desktop.
Sets National Geographic's Image of the Day as Desktop background for Mac OSX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
cd ~/Pictures/NatGeo || exit 1 | |
today="$(date +%Y-%m-%d)" | |
hostname="https://yourshot.nationalgeographic.com" | |
originalUrl="$(curl -s https://www.nationalgeographic.com/photography/photo-of-the-day/_jcr_content/.gallery.json | jq -r '.items[0].originalUrl')" | |
fullPhotoUrl="${hostname}${originalUrl}" | |
curl -s "$fullPhotoUrl" -o "national-geographic-photo-of-the-day_${today}.jpg" | |
# Set desktop background to image | |
sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db \ | |
"update data set value = '~/Pictures/NatGeo/national-geographic-photo-of-the-day_${today}.jpg'" | |
killall Dock |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to parse the JSON rather than grep the html source, that method was broken and this is far easier to manage. Also latest MacOS seems to require a
killall Dock
to actually reload the displayed picture.And passes shellcheck!