Forked from bergeycm/set_NatGeo_img_as_desktop.sh
Last active
December 17, 2022 10:51
-
-
Save rachelss/f0cfb28b5cf290f5ab32 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 hidden or 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
| #!/bin/bash | |
| cd ~/Pictures/NatGeo | |
| rm NG_img_of_day | |
| rm NG_img_of_day_site | |
| curl http://photography.nationalgeographic.com/photography/photo-of-the-day/ \ | |
| -o NG_img_of_day | |
| # Parsing HTML like this is a sin. | |
| # If it's no longer tagged with "canonical," script will break | |
| IMG_HTML=`grep "canonical" NG_img_of_day | sed -e "s/.*href=\"//" -e "s/\".*//"` | |
| curl $IMG_HTML -o NG_img_of_day_site | |
| # Another hacky bit that will fail when Nat Geo changes their image naming conventions | |
| IMG_URL=`grep "wpf/media-live/photos/000/" NG_img_of_day_site | head -n1 | \ | |
| sed -e "s/.*\(images\)/\\1/" -e "s/.jpg.*/.jpg/"` | |
| DATE=`date +%Y-%m-%d` | |
| curl http://$IMG_URL -o national-geographic-photo-of-the-day_${DATE}.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_${DATE}.jpg'" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment