Skip to content

Instantly share code, notes, and snippets.

@qykong
Created October 7, 2016 21:53
Show Gist options
  • Save qykong/02634a9768dc8c32f2d6555d9a757059 to your computer and use it in GitHub Desktop.
Save qykong/02634a9768dc8c32f2d6555d9a757059 to your computer and use it in GitHub Desktop.
Automatically change wallpapers for xfce downloading from bing
#!/usr/bin/env bash
PICTURE_DIR="$HOME/Pictures/bing-wallpapers/"
mkdir -p $PICTURE_DIR
urls=( $(curl -s http://www.bing.com | \
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
#xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/workspace0/last-image -s $PICTURE_DIR$filename
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/workspace0/last-image -s $PICTURE_DIR$filename
else
echo "Skipping: $filename ..."
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/workspace0/last-image -s $PICTURE_DIR$filename
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment