Put file names into vars

This commit is contained in:
Cedric Girard 2018-04-03 15:47:18 +02:00
parent 86c7f53ebc
commit b087727b70
1 changed files with 9 additions and 3 deletions

View File

@ -7,6 +7,12 @@ ACCESS_KEY=""
#Comma separated collection ids: https://unsplash.com/collections
COLLECTIONS=""
#Name of the jpg file to use
WALLPAPER_LOCATION=~/Images/wallpaper.jpg
#Name of the info (txt) file
INFO_LOCATION=~/Images/wallpaper.txt
#Get new random info
photo=$(curl -sf -H "Accept-Version: v1" -H "Authorization: Client-ID ${ACCESS_KEY}" "https://api.unsplash.com/photos/random?featured&orientation=landscape&collections=${COLLECTIONS}&random=${RANDOM}")
photo_url=$(echo ${photo} | jq -r ".urls.full")
@ -14,12 +20,12 @@ photo_location=$(echo ${photo} | jq -r ".location.title")
photo_username=$(echo ${photo} | jq -r ".user.name")
#Download it
curl -Lsf -o ~/Images/wallpaper.jpg ${photo_url}
curl -Lsf -o ${WALLPAPER_LOCATION} ${photo_url}
#Set as wallpaper
nitrogen --save --set-zoom ~/Images/wallpaper.jpg
nitrogen --save --set-zoom ${WALLPAPER_LOCATION}
#Put wallpaper info into text file (eg for Conky)
echo "Taken in ${photo_location} by ${photo_username}" > ~/Images/wallpaper.txt
echo "Taken in ${photo_location} by ${photo_username}" > ${INFO_LOCATION}
# vim:set ts=2 sw=2 et: