Skip to content

Instantly share code, notes, and snippets.

@regismesquita
Last active December 21, 2015 20:58
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 regismesquita/6364577 to your computer and use it in GitHub Desktop.
Save regismesquita/6364577 to your computer and use it in GitHub Desktop.
Just a tool for a dynamic background with images from artsicle... Made for fun and training shell
# Uses:
# folder=/path/to/arts origin=artsicle_username WAIT_TIME=1 FORMAT=zoom ./art_grabber.sh
# ./art_grabber.sh
folder=${folder:=/tmp/arts} # Folder for cache the images
origin=${origin:=regisdsm} # Your artsicle username
WAIT_TIME=${WAIT_TIME:=300} # Time between each wallpaper in seconds
FORMAT=${FORMAT:=spanned} # Possible values are "none", "wallpaper", "centered", "scaled", "stretched", "zoom", "spanned".
#Create and change folder
mkdir -p $folder
cd $folder
#Sets wallpaper format
gsettings set org.gnome.desktop.background picture-options $FORMAT
#Main Loop
while [ 1 -lt 2 ]; do
#Get art list from artsicle
echo 'Getting Art List from artsicle'
url_list=$(curl https://www.artsicle.com/$origin | grep main | grep artist | grep href | grep -v img | cut -f2 -d\" | sed -e 's/^/http:\/\/www.artsicle.com/g')
# Get arts urls and make it fullpath
echo 'Checking if images are available local else downloading'
for url in $url_list; do
filename=${url##*/} # Remove URL host from filename
filename=${filename%\#*} #remove args from filname
if test ! -e $filename #Check if file is present otherwise downloads
then
echo $filename ' - Not Local Downloading'
echo 'Lets get the image url'
imageurl=$(curl -L "$url" | grep zoom_image | tr ' ' "\n" | grep src | cut -f2 -d\") # Extracts fullsized image from page
echo 'done... lets get the file and go on'
wget $imageurl -O $folder/$filename #Downloads image using chopped filename as final name
else
echo $filename ' - Local'
fi
done
#Picture show cycle
for i in $(ls); do
echo 'Time to show the pictures, lets start with ' $i
gsettings set org.gnome.desktop.background picture-uri file://$folder/$i; sleep $WAIT_TIME;
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment