Interesting problem. I only have one display, but found an elegant way to select a file randomly from a directory (thanks to Antonín Dach)
#Get a random file from $DIRNAME.
PIC=$(find "$DIRNAME" -type f | shuf -n 1 --random-source=/dev/random)
This only picks one file at random from $DIRNAME, so for two displays, you need “shuf” to return 2 lines with “shuf -n 2”. But then you need an array. If there are no spaces in your filename, bash can work its magic with
# PIC is now a two element array (if your files have no spaces)
PIC=($(find ~/Pictures/Wallpaper -type f | shuf -n 2 --random-source=/dev/random))
You can use “mapfile” if your files contain spaces, but I admit I don’t really get bash syntax sometimes (what is “< <” ??)
# PIC is now a two element array, even if your filenames contain spaces
mapfile -t PIC < <(find "$DIRNAME" -type f | shuf -n 2 --random-source=/dev/random)
Bash certainly has very elegant ways of doing things, if you can crib enough tips and tricks from the gurus on the internet 