Skip to content

Instantly share code, notes, and snippets.

@ccnokes
Last active May 18, 2019 17:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ccnokes/4b98664514857a58a135b6ddb4b2c7fc to your computer and use it in GitHub Desktop.
Save ccnokes/4b98664514857a58a135b6ddb4b2c7fc to your computer and use it in GitHub Desktop.
Set your wallpaper to the current Astronomy Picture of the Day (APOD)
# get the URL of the current Astronomy Picture of the Day (APOD)
apod_url=$(curl -s https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY | jq -r '.hdurl')
# get just the image name from the URL
filepath=$(basename "$apod_url")
# Now get the image and save it
curl -s -o "$filepath" "$apod_url"
# Use AppleScript to set it as the wallpaper
osascript -e "tell application \"Finder\" to set desktop picture to POSIX file \"$PWD/$filepath\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment