Advertisement
Guest User

jamk.sh

a guest
Apr 27th, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. # Download random images from wallhaven.cc
  3. # By ponyashka
  4.  
  5. FOLDER=~/wallhaven
  6. WALL=~/wallhaven/list.txt
  7.  
  8. [ -d ${FOLDER} ] && rm ${FOLDER}/* || mkdir -p ${FOLDER}
  9. [ -e ${WALL} ] && rm ${WALL}
  10.  
  11. down() {
  12. for num in {1..2}; do
  13. curl -s "https://alpha.wallhaven.cc/search?q=&resolutions=1920x1080&sorting=random&page=$num" --compressed |
  14. grep -o -E 'https://alpha.wallhaven.cc/wallpapers/thumb/small/th-([0-9]+)' |
  15. cut -f2 -d '-' >> ${WALL}
  16. done
  17.  
  18. for list in $(cat ~/wallhaven/list.txt); do
  19.  
  20. wget --quiet -O ${FOLDER}/${list}.jpg "https://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-${list}.jpg"
  21. FILE="${FOLDER}/${list}"
  22.  
  23. if [ $(du -h ${FILE}.jpg | cut -f1) = "0" ]; then
  24. rm ${FILE}.jpg
  25. wget --quiet -O ${FOLDER}/${list}.png "https://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-${list}.png"
  26. fi
  27. done
  28. }
  29. down &>/dev/null &
  30.  
  31. pid=$!
  32. spin[0]="-"
  33. spin[1]="\\"
  34. spin[2]="|"
  35. spin[3]="/"
  36.  
  37. echo -n "Downloading wallpapers... ${spin[0]}"
  38. while kill -0 $pid &>/dev/null
  39. do
  40. for i in "${spin[@]}"
  41. do
  42. echo -ne "\b$i"
  43. sleep 0.1
  44. done
  45. done
  46.  
  47. printf "\nFinished! All wallpapers has been saved on ${FOLDER}\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement