#!/usr/bin/env bash # author: gotbletu (@youtube|github|odysee) # https://www.youtube.com/user/gotbletu # desc: a script to download random wallpaper and delete old wallpaper at the sametime (wallhaven.cc) # demo: https://www.youtube.com/watch?v=cDtVEXjiKTw # depend: curl grep sed findutils coreutils wget # Variable (you can change any of these to your liking) savedir=~/Pictures/Wallpapers tempdir=/tmp/wallpaper_wallhaven expire_date=30 # create folders mkdir -p $savedir mkdir -p $tempdir cd $tempdir || exit # change the url if you need different resolutions curl -f -L 'https://wallhaven.cc/search?categories=111&purity=100&resolutions=1920x1080&sorting=random&order=desc&ai_art_filter=1' | grep -Eo "https?://\S+?\"" | grep small | cut -d '"' -f1 | sed -e 's@//th@//w@g' -e 's/small/full/g' -e 's@/@/wallhaven-@5' | while read -r link ; do wget --timestamping "$link" || wget --timestamping "${link//.jpg/.png}" ; done # # get links of images and download it # get_random_url=$(lynx -listonly -nonumbers -dump "https://wallhaven.cc/random" | grep '/w/') # get_images_url=$(echo "$get_random_url" | while read -r line; do lynx -source "$line" | grep -Po '