Return to Snippet

Revision: 48514
at July 4, 2011 10:07 by ksaver


Initial Code
#!/usr/bin/env bash
#  shiftwallpaper.sh
#  A very simple bash script to shift wallpaper every n seconds.
#  Turns your desktop in a kind of digital frame :-)
#  Tested in and for Fluxbox [TM].
#  Public Domain Code. No Warranty at all.
#  ksaver, July 2011.

# Modify this line to you own wallpapers directory.
WALLPAPER_DIR="$HOME/MyPictures/Wallpaper"

# Set interval in seconds to shift wallpaper.
WAIT=120

function load_wallpapers()
{
    # Load the wallpaper list into an array
    # loads new wallpapers added to directory in runtime.
    n=0
    for wallpaper in "$1/*"; do
        wallpaper_list[n]=$wallpaper
        let n=$n+1
    done
}

function rotate_wallpapers()
{
    # Rotate wallpaper every n seconds.
    for wallpaper in ${wallpaper_list[@]}; do
        /usr/bin/env fbsetbg -F $wallpaper
        sleep $1
    done
}

## main()
while [ True ]; do
    load_wallpapers   $WALLPAPER_DIR
    rotate_wallpapers $WAIT
done

Initial URL
http://pastebin.com/itGaLPti

Initial Description
I turned an obsolete laptop in a kind of digital frame :-)

Initial Title
Shiftwallpaper.sh: shift wallpaper every n seconds.

Initial Tags

                                

Initial Language
Bash