I know this is a very basic function, and far from original, but I’m putting it here for the benefit of newcomers, and to help fill out the forum with more examples of simple but effective configuration ideas. I hope it will be helpful.
The purpose is to have a “wallpaper” menu, which will display automatically generated thumbnails from the relevant folder. The selected wallpaper should be shown on the current desktop only, and automatically reproduced on that desktop the next time FVWM is started.
First, create the location for the wallpaper menu, in another menu:[code]DestroyMenu MenuConfig
AddToMenu MenuConfig
- “FVWM Help” Popup MenuFvwmHelp
- “Wallpaper” Popup MenuWallpaper
…[/code]
Then create the wallpaper menu. Since menu changes depending on the contents of the wallpaper folder, it must be dynamic:[code]DestroyMenu MenuWallpaper
AddToMenu MenuWallpaper foo title
- DynamicPopupAction Function WallpaperBrowser[/code]
Define the WallpaperBrowser function, which will be run each time the wallpaper menu is selected, and will generate the wallpaper menu:[code]DestroyFunc WallpaperBrowser
AddToFunc WallpaperBrowser
- I DestroyMenu recreate MenuWallpaper
- I AddToMenu MenuWallpaper “Wallpaper - desk $[DESK.N]” title
- I PipeRead ‘$[HOME]/.fvwm/scripts/wallpaper.sh $[HOME]/wallpaper $[DESK.N]’[/code]
The menu will have title Wallpaper - desk X where X is the current desktop number. The script “wallpaper.sh” should be something like the following:#!/bin/sh [ -d $1/.thumbs ] || mkdir $1/.thumbs for pic in `find $1/* -exec basename {} .jpg \;`; do [ -f $1/.thumbs/$pic.png ] || convert -quality 0 -resize 48 $1/$pic.jpg $1/.thumbs/$pic.png echo "+ %$1/.thumbs/$pic.png%\"$pic\" exec exec \`ln -sf $1/$pic.jpg $1/.current-$2-fvwm && xloadimage -fullscreen -onroot $1/$pic.jpg\`" done
This first creates any missing thumbnails in a folder called ~/wallpapers/.thumbs, then generates the menu entries, complete with thumbnails, and echos them back to the WallpaperBrowser function to display on your menu.
The action for the selected menu is to create a link to “current-X-fvwm” where X is the desktop number. So now, simply use the FvwmBacker function to load the wallpaper pointed to by the link relevant for each desktop. Add + I Module FvwmBacker
to your start function, and the following configuration for FvwmBacker to your configuration:[code]DestroyModuleConfig FvwmBacker: *
*FvwmBacker: Command (Desk 0, Page * *)
Exec exec xloadimage -onroot -fullscreen $[HOME]/wallpaper/.current-0-fvwm
*FvwmBacker: Command (Desk 1, Page * *)
Exec exec xloadimage -onroot -fullscreen $[HOME]/wallpaper/.current-1-fvwm
…
[/code]
This uses xloadimage to load the wallpapers. Many other programs can also do this, and everyone has their favourite.
Please do add comments, point out inaccuracies/improvements etc…