random backgrounds


Forum: X and Fluxbox
Topic: random backgrounds
started by: libretto

Posted by libretto on Sep. 04 2004,16:36
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 ???

Posted by mikshaw on Sep. 04 2004,18:08
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))]}"

Posted by libretto on Sep. 04 2004,22:41
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:

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.