LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (http://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   Scripting Changing Backgrounds in Fluxbox (http://www.linuxquestions.org/questions/linux-desktop-74/scripting-changing-backgrounds-in-fluxbox-910568/)

frankbell 10-27-2011 09:21 PM

Scripting Changing Backgrounds in Fluxbox
 
This is based on a little script I found when I was playing with FVWM.

I have spent almost an hour looking for the original so I could give the actual author credit. If anyone knows the source, please post it.

This is the original.

It selects a random background from the designated directory and changes it every 30 minutes.

Code:

#!/bin/sh

while true; do
        find ~/wallpapers -type f \( -name '*.jpg' -o -name '*.png' \) -print0 |
                shuf -n1 -z | xargs -0 feh --bg-fill
        sleep 30m
done

It was designed to be inserted in an .xinitrc file as /path/to/foo.sh & (the "&" keeps it running for the duration of the session) and called before exec fvwm. I suspect it could work with almost any window manager when called from .xinitrc.

I tested it today with Fluxbox's fbsetbg command and it works just fine when called from the Fluxbox startup file as /path/to/foo.sh &. As you see, all I did was substitute an fbsetbg command for the feh command. Because fbsetbg already has a "random" argument, I was able to discard all the "find" stuff.

If you have Fluxbox installed, see the fbsetbg help (fbsetbg -h) for an explanation of the switches.

Code:

#!/bin/sh

while true; do
        fbsetbg -f -R ~/wallpapers
        sleep 30m
done

I really enjoy watching all the beautiful wallpapers I've collected go by (I favor landscape scenery). I thought others might have fun with it.


All times are GMT -5. The time now is 08:39 AM.