Skip to content

Instantly share code, notes, and snippets.

@fmarot
Last active June 24, 2018 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmarot/9e7f8af34ff784d1fc5fedf44472b73b to your computer and use it in GitHub Desktop.
Save fmarot/9e7f8af34ff784d1fc5fedf44472b73b to your computer and use it in GitHub Desktop.
#!/bin/bash
#If we do not sleep, the network is not available :( => we should use systemd !!!
sleep 8
# inspired by http://disq.us/p/1anwvre
# requires to set wallpaper mode as slideshow from ~/wallpaper
echo "`date`" >> getBingWallpaper.log
cd $(dirname $0)
img=$(wget -qO - https://www.bing.com | grep -o "url:.*1920x1080.jpg" | cut -d'"' -f2)
[ -z "$img" ] && exit 1
fname=`basename $img`
if [ ! -f ~/wallpaper/$fname ]; then
echo "file ~/wallpaper/$fname does not exist... yet ;)"
echo "file ~/wallpaper/$fname does not exist... yet ;)" >> getBingWallpaper.log
wget -P /tmp/ -qN https://www.bing.com$img || exit 1
rm ~/wallpaper/*.jpg
mv /tmp/$fname ~/wallpaper
else
echo "file ~/wallpaper/$fname already exists. Not downloading again..."
echo "file ~/wallpaper/$fname already exists. Not downloading again..." >> getBingWallpaper.log
fi
@fmarot
Copy link
Author

fmarot commented Jun 24, 2018

2018-06-24 new compatibility with Bing having now more than one resulting image returned by wget command

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