This is a non-repeating wallpaper changing script I've been trying to get working for the last 3 days. Originally, I wanted it to echo the file name to a file on a new line every time it was set and if the file had lines equal to the number of files in said directory, it would remove the list file and retouch it so it could be echo'd to again, but that ran into a few snags...so I went with method 2. Move the file after it was set and when the file count got to 1, move the last file and then move all the files back to the first directory.

#!/bin/bash until [ 1 -eq 2 ]; do DIR="$HOME/.wallpaper/" PIC=$(find $DIR -type f | shuf -n1) WPC=$(find $DIR -type f | wc -l) if [ "$WPC" = "1" ]; then mv $HOME/.wallpaper-used/*.{jpg,png,jpeg} $HOME/.wallpaper/ && nitrogen --set-scaled "$PIC" && mv "$PIC" $HOME/.wallpaper-used && sleep 20s else nitrogen --set-scaled "$PIC" && mv "$PIC" $HOME/.wallpaper-used && sleep 20s fi done

Of course, the prerequisites are:

- Nitrogen(I prefer this over feh, but you can switch it to feh if you wish)

- folders in your users home directory named .wallpaper and .wallpaper-used

- files to populate ~/.wallpaper with(jpg, png, or jpeg formats only unless you add the extension you wish to use to both line with {jpg,png,jpeg} in them.

user-edit: Changed the method of getting the files and the number of files at the urging of many who have pointed me to the BashGuide which says to use find rather than ls so I complied. But of course credit for the switch goes to Alad who first pointed such an egregious error on my part.

Last edited by Sachiko (2016-09-01 14:40:28)