For no particular reason, I was trying to figure a way to make my wallpaper switch randomly on each startup. After some brief googling around and some experimentation, I came up with this brief script that does the work just nice. (Alright, it may not be the neatest, fastest, or easiest way of doing it, but its the first thing that came in my mind. Hope it helps.)
Well before that here’s the list of assumptions: I use bsetbg for setting the wallpaper. You might want to use fbsetbg, fbsetroot or whatever. Also, I’m picking up the images from a folder in ~/pictures/recent. You might want to change that one too if you want to use the same script. And finally, I use Fluxbox, so I just need to mention this script in Fluxbox’s startup file to make it run each time. You’ll have to do similar stuff depending on your Window Manager, or just run a cron job or something.. So alright, here’s the file:
#randwall.sh: Randomly sets wallpaper each time it’s run
#Count how many images are there in my folder..
WCOUNT=`ls -1 ~/pictures/recent/* | wc -l`;
#Generate a random number within that range..
num=$[ ( $RANDOM % $WCOUNT ) + 1 ];
#Pick up that particular image..
MYPIC=`ls ~/pictures/recent/* |sed -n ‘ ‘$num’p ‘`;
#and set it as the wallpaper!
Update: I know, I know, I’m a real idiot. I just found out you can do the exact same thing using fbsetbg -r folder-name. Oh well, at least it was useful learning about $RANDOM and all..