#!/bin/sh echo "DISPLAY:$DISPLAY" Dir="/home/n/img/wallpap/2560x1440/" wallpaplist="/home/n/.cache/wallpaplist" contact="n@tourmentine.com" if [ ! -d "$Dir" ]; then echo "${Dir} does not exist" exit 1 fi if [ ! -f ${wallpaplist} ]; then touch ${wallpaplist} fi while true; do AvailableFiles=$(find ${Dir} | wc -l) AlreadyViewedFiles=$(cat ${wallpaplist} | wc -l) TotalFiles=$((AvailableFiles-AlreadyViewedFiles)) if [ "$TotalFiles" -lt 1 ]; then echo "*** Seems we have displayed all available wallpapers; let's do the time warp...again. ***" printf ""> ${wallpaplist} echo "" | /usr/bin/mail -s "Seems we have displayed all available wallpapers; let's do the time warp...again." ${contact} TotalFiles=$AvailableFiles fi RandomNumber=$(shuf --input-range=1-"$TotalFiles" --head-count=1) test ! "$RandomNumber" = 0 || RandomNumber=1 RandomFile="$(find ${Dir} -type f -printf '%f\n' | sort | grep -w -v -F -f ${wallpaplist} | head -n "$RandomNumber" | tail -n 1)" if [ "${RandomFile}" = "" ]; then echo "*** Oops, something went wrong. erasing cache for security ***" printf ""> ${wallpaplist} echo "" | /usr/bin/mail -s "Oops, something went wrong. erasing cache for security" ${contact} exit 1 else echo "${RandomFile}" >> ${wallpaplist} fi export DBUS_SESSION_BUS_ADDRESS DBUS_SESSION_BUS_PID AlreadyViewedFiles=$(cat ${wallpaplist} | wc -l) echo "" | /usr/bin/mail -s "New wallpaper: ${RandomFile} (${AlreadyViewedFiles}/${AvailableFiles})" ${contact} echo "Selected File: $RandomFile, which is the ${AlreadyViewedFiles}th out of ${AvailableFiles}" for workspace in 1 2 3 4 do xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorDisplayPort-${workspace}/workspace0/last-image -s "${Dir%/}/${RandomFile}" 2>/dev/null done sleep 3h done