Created
December 9, 2015 18:04
-
-
Save bergeycm/95c6b84fcdb70f199cfb 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
#!/bin/bash | |
cd ~/Pictures/NatGeo | |
rm NG_img_of_day | |
rm NG_img_of_day_site | |
rm national-geographic-photo-of-the-day_*.jpg | |
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 second desktop background to image | |
CMD="tell application \"System Events\" to set picture of desktop 2 " | |
CMD+="to \"/Users/bergey/Pictures/NatGeo/" | |
CMD+="national-geographic-photo-of-the-day_${DATE}.jpg\" as POSIX file" | |
echo $CMD > osa_tmp.sh | |
osascript osa_tmp.sh | |
rm osa_tmp.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment