X and Fluxbox :: random backgrounds



Hello there,

Looking to get the background wallpapers changed based on picking a random file from a directory. I understand that fluxbox should have the 'fbsetbg' command and passing -R option makes it choose a random pic. You can even add a line to cron to do it automatically.

Basically, is fbsetbg included in fluxbox that comes with DSL, or do I need to get one of the later versions of fluxbox for this to work ???

fbsetbg is a shell wrapper which contains an extra piece of script to choose a random image from the given directory.  It's not included with DSL, since there is already the bsetbg wrapper and xsri.
You could build a small script to do this with existing applications.  something like:
Code Sample
#!/bin/sh
pic_dir=/home/user/.fluxbox/backgrounds
num_pics=`ls -Al "$pic_dir" | grep ^- | wc -l | tr -d ' '`
bg_pics=`find "$pic_dir/*"`
pic_array=($bg_pics)

bsetbg -f "${pic_array[$((RANDOM%num_pics))]}"

Ok thanks for the code I will try it later.

[EDIT] Took out the star (*) in the bg_pics line adn the code works!

Cheers, Libretto :cool:


original here.