Module FvwmPerl
AddToFunc . I SendToModule FvwmPerl eval $*
# find all available background images for a later use
. $a = $ENV{HOME} . "/bg"; opendir DIR, $a; @b = grep { /png$/ } readdir(DIR); closedir DIR
# build a menu of all available background images
AddToMenu MyBackgrounds "My Backgrounds" Title
. foreach $b (@b) { command("AddToMenu MyBackgrounds '$b' Exec fvwm-root $a/$b") }
# choose a random background to load on start-up
. command("AddToFunc InitFunction I Exec exec fvwm-root $a/" . $b[int(random(@b))])