Monday, August 17, 2009

mrlogan’s random wallpaper script

mrlogan has posted this great little script on the A320 freeforums:

I like my wallpapers randomized but I had trouble trying to store the file names in an array so I came up with an alternative script. I thought I would include it in case anyone has been looking for one.

cd /usr/local/dmenu/wallpaper
#change the above line to where ever you store your wallpaper
COUNT=`ls *.png -l | wc -l`
FILES=`ls *.png`
let SELECT=$RANDOM%$COUNT
echo "Selecting File Index " $SELECT "From " $COUNT "Files"
ctr0=0
for F in $FILES; do
  if [ $ctr0 -eq $SELECT ]; then
    RANDOMFILE=$F
    echo "found it!"
  fi
  let ctr0=$ctr0+1
done
echo "File selected is " $RANDOMFILE
#change this line below to point to where ever your default wallpaper is
cp $RANDOMFILE wallpaper.png


I put mine in a file (like random.sh) and execute it the main script in the sbin folder before it loads the menu up.

No comments :

Post a Comment