Functions are one of my favorite things to use (as you noticed I write a function even for simple tasks). As is true with almost anything you want to program, being able to write good functions is the key. Almost all of the advanced sections are gonna include functions, so this part is just filled with miscellaneous functions.

These first two functions are taken from taviso's fvwm2rc file. They use the tools from ImageMagick to take screen shots of an open window and then use it for an Icon. The first function Thumbnail will use the screenshot of the current window and use that as the Icon for its Iconified state.

DestroyFunc Thumbnail
AddToFunc Thumbnail
+ I Raise
+ I SetEnv Icon-$[w.id] $[w.iconfile]
+ I ThisWindow (!Shaded Iconifiable !Iconic) PipeRead \
    "xwd -silent -id $[w.id] | convert -scale $$(($[w.width]/5)) -frame 1x1 \
    -mattecolor black -quality 0 xwd:- png:$[fvwm_tmp]/icon.tmp.$[w.id].png \
    && echo Nop"
+ I TestRc (Match) Test (f $[fvwm_icon]/$[w.iconfile], f $[fvwm_tmp]/icon.tmp.$[w.id].png) \
    PipeRead "composite -geometry +2+4 \
    $[fvwm_icon]/$[w.iconfile] $[fvwm_tmp]/icon.tmp.$[w.id].png \
    $[fvwm_tmp]/icon.tmp.$[w.id].png && \
    echo WindowStyle IconOverride, Icon $[fvwm_tmp]/icon.tmp.$[w.id].png || echo Nop"
+ I TestRc (NoMatch) WindowStyle IconOverride, Icon $[fvwm_tmp]/icon.tmp.$[w.id].png
+ I Iconify

DestroyFunc DeThumbnail
AddToFunc DeThumbnail
+ I PipeRead "echo WindowStyle Icon \\$\\[Icon-$[w.id]\\]"
+ I UnsetEnv Icon-$[w.id]
+ I Exec rm -f $[fvwm_tmp]/icon.tmp.$[w.id].png

These functions can be used in place of 'Iconify'. The function Thumbnail will first take a screenshot of the current window and then write it to a temp file. The temp file is put in the dir $[fvwm_tmp], so you must have that enviorment variable set. The function then looks to see if you have have an Iconfile set for the window, 'Test (f $[fvwm_home]/icons/$[w.iconfile])'. This fill will only exist if you set it using a style command, for example 'Style "Firefox-bin" Icon 48x48/firefox.png' well set $[w.iconfile] to be 48x48/firefox.png (note that I set up so my icons are all in my $[fvwm_icon] dir). If this file exists then the function will 'composite' those two pics into one icon. Either way, it then sets the new Icon to be the screenshot image we just created and Iconifies the window. The DeThumbnail function cleans things up, it sets the icon back to its original state and then removes the temp icon it created so the next time the window is Tumbnailed it will behave the same as the first. There are two ways to make sure this function is run when an window is deiconified. One way is to also add an '+ I Iconify' to this function and bind it so its ran when you deicnoify a window. Or what I prefer is set up the module FvwmEvent to run this at the time the window is deiconified. This is nice cause then it doesn't matter how the icon is deiconified, this function will still run. To do this set up FvwmEvent as follows and then load the module at startup in your StartFunction.

#####
# FvwmEvent
###########
DestroyModuleConfig FvwmEvent: *
*FvwmEvent: deiconify DeThumbnail

One last note about these functions is that when you 'Restart' FVWM all the Icons are converted back to their original state and you have to deiconify then iconify the windows again to get things working. One way to work around is with adding '+ I All (Iconic) ReThumbnail' to your RestartFunction, where ReThumbnail is the following function.

DestroyFunc ReThumbnail
AddToFunc   ReThumbnail
+ I Iconify
+ I Thumbnail

If everything is set up correctly then your Icons for your Iconified windows should look something like these two examples for firefox and gvim.

Another function that taviso wrote, he calls FvwmExpose. This function is like the WindowList function. What it does is uses ImageMagick to take a sreenshot of all the open windows and then put them into a menu using the screenshot as the icon. Here is a copy of his function.

#####
# FvwmExpose
###########
DestroyFunc FvwmExpose
AddToFunc FvwmExpose
+ I AddToMenu FvwmExposeMenu "e x p o s e" Title
+ I + DynamicPopDownAction DestroyMenu FvwmExposeMenu
+ I All (!Iconic !Shaded AcceptsFocus)\
    PipeRead "echo Raise; \
        xwd -silent -id $[w.id] | convert -scale $$(($[w.width]/10)) -quality 0 xwd:- \
        png:$[fvwm_home]/tmp/icon.exp.$[w.id].png \
    && echo AddToMenu FvwmExposeMenu \
    %$[fvwm_home]/tmp/icon.exp.$[w.id].png%\\\'\"$[w.name]\"\\\' WindowID $[w.id] WarpToWindow 50 50 \
        && echo AddToMenu FvwmExposeMenu \\\"\\\" Nop \
    || Nop"
+ I Popup FvwmExposeMenu
+ I Exec exec rm -f $[fvwm_home]/tmp/icon.exp.*

Call this function from a binding, I use meta+middle mouse click, and it will popup the FvwmExposeMenu. Here is an example of what that menu will look like.


Advanced Topics index Advanced Menu