Skip to content

Instantly share code, notes, and snippets.

@ninehills
Created May 25, 2015 09:06
Show Gist options
  • Save ninehills/45e94296cb4556f9bdf7 to your computer and use it in GitHub Desktop.
Save ninehills/45e94296cb4556f9bdf7 to your computer and use it in GitHub Desktop.
Auto download bing wallpapers.
#!/usr/bin/env bash
PICTURE_DIR="$HOME/Pictures/bing-wallpapers/"
mkdir -p $PICTURE_DIR
BING_URL="http://global.bing.com/?FORM=HPCNEN&setmkt=en-us&setlang=en-us#"
urls=( $(curl -s $BING_URL | \
grep -Eo "url:'.*?'" | \
sed -e "s/url:'\([^']*\)'.*/http:\/\/bing.com\1/" | \
sed -e "s/\\\//g") )
for p in ${urls[@]}; do
filename=$(echo $p|sed -e "s/.*\/\(.*\)/\1/")
if [ ! -f $PICTURE_DIR/$filename ]; then
echo "Downloading: $filename ..."
curl -Lo "$PICTURE_DIR/$filename" $p
else
echo "Skipping: $filename ..."
fi
done
@ninehills
Copy link
Author

$ crontab -l

min hour mday month wday command

20 9,12,15,19,22 * * * sh -x /bin/bing-wallpaper.sh &>/bin/bing-wallpaper.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment