I concoted this from exisiting code over the internet. This code displays a random image from a specified directory (all subdirectories included) as a wallpaper in lxde. This is working for me under arch linux.

#!/bin/bash
DIR="/put/your/directory/here"

# failsafe - fall back to current directory
[ "$DIR" == "" ] && DIR="."

# save and change IFS
OLDIFS=$IFS
IFS=$'\n'

# read all file name into an array
fileArray=($(find $DIR -name "*.jpg"))

# restore it
IFS=$OLDIFS

# get length of an array
tLen=${#fileArray[@]}

FLOOR=1
while [ 1 -eq 1 ]; do
number=$RANDOM
while [ "$number" -le $FLOOR ]; do
number=$RANDOM
done
let "number %= ${tLen}"  # Scales $number down within $RANGE.
pcmanfm --set-wallpaper "${fileArray[$number]}"  --wallpaper-mode=fit
sleep 10m
done 
About these ads