Sometimes you just have so many good pictures, that you do not know which one you want to use as your background. This burden of choice can simply be resolved by iterating over all the possibilities. The best of all worlds.

If you are using a more fleshed out window manager, this might be worked into the functionality already. If, like me, your laptop dates back from your high school days and if, like me, those are indeed long behind you, then you might be using a very simple setup to not strain your hardware. Or you just might prefer things simple. Like me.

I am an i3 user myself (on my laptop) and i3 does not even include background setting functionality, let alone iterating over a few of them. Of course, this need not be a problem in the Linux world. Indeed, there is a simple program called feh which, beyond being able to be used as an image viewer, can also manage the background for you.

feh does lack the ability to iterate automatically every so often, but that never stopped anyone. Since feh works from the command line, we can simply use crontab. We will also use find to actually get the files. In my case, my background pictures are located in the folder ~/Dropbox/bg/. To list them I can use find ~/Dropbox/bg/ -name '*.jpg' -o -name '*.png' and to get a random one out of that list, I can use shuf.

Throwing everything together. Open crontab by issuing crontab -e, then add the line

* * * * *  DISPLAY=:0.0 feh --bg-scale "$(find ~/Dropbox/bg/ -name '*.jpg' -o -name '*.png' | shuf -n1)"

This will change the background into something random from the designated folder every minute. The DISPLAY=:0.0 insures feh knows what screen to put the image on. The * can be adjusted to your needs, see cron manual for precise work on that. Notice that since the find command returns a list of filepaths, you can just as easily create a textfile with all the paths to the pictures you want to use and run that through shuf instead of the find output.

A commenter notes I can use the -z flag of feh rather than using shuf. I believe this was not yet an option when I wrote this post. If it was, then silly me for missing it.