Easiest Thumnails Ever!

I wrote a module to generate thumnailed icons. It has a number of advantages over the taviso’s original pipereads: It’s easier to use; it’s more efficient; it can do multiple sets of icons using different scales.

To use, its’s as easy as this:

[code]DestroyModuleConfig FvwmThumbnail: *

*FvwmThumbnail: Refresh 5
*FvwmThumbnail: Directory /home/nick/lab/fvwm_thumbs

*FvwmThumbnail: Class Pager, ScaleTo 27x27
*FvwmThumbnail: Class Pager, Command “WindowId %w WindowStyle EWMHMiniIconOverride, MiniIcon %i”

*FvwmThumbnail: Class Icons, Factor 0.2x0.2
*FvwmThumbnail: Class Icons, Command “WindowId %w WindowStyle IconOverride, Icon %i”

*FvwmThumbnail: Class BigPager, Factor 0.166666x0.166666

AddToFunc StartFunction + I Module FvwmThumbnail
[/code]

The Class keyword defines a scaling class. Each scaling class generates icons scaled as per Factor if given. If not, factors are generated to scale the desktop into the geometry supplied to ScaleTo. It’s also possible to supply your own custom scaling subrouting in perl - but that’s untested as yet.

Refresh defines the number of seconds between refreshes of the current window. The config above updates the current window thumbs every 5 seconds.

Command is a command string sent to FVWM when a thumbnail is generated. %w expanded into the window ID and %i into the full path of the icon file.

Here’s some nice big transparent icons generated using the above:

And a pager with miniicons likewise.

You can support more scaling classes than these. I defined a class to generate 1/6th scale thumbs for use in a Big Pager. BigPager uses miniicons for the windows. If we use command to set the miniicon we mess up the small pager.

Luckily FvwmThumbnail supports an Apply command via SendToModule. Add this to the BigPager invocation func:

+ I SendToModule FvwmThumbnail Apply BigPager WindowId %w WindowStyle EWMHMiniIconOverride, MiniIcon %i
And the BigPager icon class will be applied using the command given. % fields are expanded as above.

To use the module, stick it in your ModulePath and chmod +x. Feedback, especially bug reports, would be much appreciated. Thanks.

[edit] uploaded a pic and forgot to link to it. D’oh!

[color=red]Edited by theBlackDragon:
–> Moved from Complex functions
–> Fixed the link to the module (phpBB makes all links not starting with a protocol relative it seems…)[/color]

This must be the coolest thing yet to see on external fvwm “plugins” … It is starting to drive fvwm over mac wm :wink:
One question: can you somehow use/add in it the composite command? Ie, you get the grab of window content combined with mini-icon defined with the program name?

I get this error

/usr/bin/perl: symbol lookup error: /usr/lib/perl5/site_perl/5.8.5/powerpc-linux/auto/Image/Magick/Magick.so: undefined symbol: InitialzeMagick

Any idea’s. Also where did you get that awsome super girl background.

Thanks
VoiDeR

[quote=“VoiDeR”]

/usr/bin/perl: symbol lookup error: /usr/lib/perl5/site_perl/5.8.5/powerpc-linux/auto/Image/Magick/Magick.so: undefined symbol: InitialzeMagick

Typing mistake:

InitialzeMagick --> InitializeMagick

– Thomas Adam

:smiley: And I don’t think we’ve scratched the surface yet!

Next I think I might write an ring menu module, maybe with some cool animation options. I’d also like to write a fadeout module that swallows windows, and them gradually alpha blends them until they disappear. Just so we can have some cool fading captions like on WindowMaker and Enlightenment.

Not quite yet. Give me a couple of days and you’ll be able to supply your own image transformation subroutines which will let you do anything to the images you can imagine. Well, subject to the limitations of image magick, obviously :slight_smile: I might see if I can add some options specifically for composition as well. I’ll have to have a play.

Which is weird, since I don’t call that routine in my code. VoiDeR, I’d guess your Image::Magick install is broken. Can you update/reinstall?

It’s home grown. Well, partly; I found the base pic online somewhere, You want a copy?

I think you lost me somwhere back at:

seriously though. This module will generate thumbnails the same as taviso’s original thumbnail function but do it better? How to I invoke it. For instance I bound my mouse button 6 to the Thumnail function. So I thought that if this Module is used instead. I would substitute the FvwmThumbnail module for the original function. Nothing happens however when I try. Well actually I get errors. Like this:

using /home/catherine/.fvwm/thumnails
Config END
storing icons in /home/catherine/.fvwm/thumnails
refresh time = 5
Use of uninitialized value in division (/) at /usr/lib/fvwm/2.5.12/FvwmThumbnail line 210.
Illegal division by zero at /usr/lib/fvwm/2.5.12/FvwmThumbnail line 210.
DESTROY created new reference to dead object 'FVWM::Module' during global destruction.
refresh time: 5
using /home/catherine/.fvwm/thumnails
Config END
storing icons in /home/catherine/.fvwm/thumnails
refresh time = 5
No running windows found
*** loading the extensions datasource
art_render_invoke: no image source given
art_render_invoke: no image source given
X Error of failed request:  BadDrawable (invalid Pixmap or Window parameter)
  Major opcode of failed request:  14 (X_GetGeometry)
  Resource id in failed request:  0xe01ab1
  Serial number of failed request:  7
  Current serial number in output stream:  7

Well. maybe not exactly like taviso’s function. I’ve got so used to dealing with second and third generation descendants that I must have forgotten how the original works.

This one assumes that you want thumbnails taken when a window opens; on focus; and at regular intervals thereafter. It’s supposed to be launched at config startup and to happen automatically in the background.

That’s not how you expected it to work, so I guess need to work on the interface a bit more. Maybe setting Refresh = 0 to supress auto thumnailing and a send to module command to thumbnail the current window?
[edit] couple of typos

I just did emerge -pv perlmagick and according that to it hasnt even been installed. Its funny though cause i have man page for Image::Magick. I have to downgrade my current version of imagemagick inoder to install perlmagick. So ill let you know what happens in a few hours when its done compiling. Oh id love a cp of that background. Ill add it to my other super chick backgrounds :smiling_imp:

Thanks
VoiDeR

New version. This one is documented - pod2html FvwmThumbnail will getnerate a html format man page. You can get *roff using pod2man instead. There’s now a Mode flag for manual control of the thumnailing process and lots of bugfixing.

@chickpea: this one should do what you want. Configure it thusly:

[code]*FvwmThumbnail: Mode Manual
*FvwmThumbnail: Refresh 0
*FvwmThumbnail: Directory $[FVWM_USERDIR]/fvwm_thumbs

*FvwmThumbnail: Class Icons, Factor 0.2x0.2
*FvwmThumbnail: Class Icons, Command “WindowId %w WindowStyleIconOverride, Icon %i”

*FvwmThumbnail: Class Pager, ScaleTo 27x27
*FvwmThumbnail: Class Pager, Command “WindowId %w WindowStyle EWMHMiniIconOverride, MiniIcon %i”

Key T A 4 ThisWindow SendToModule FvwmThumbnail Thumbnail $[w.id]

AddToFunc StartFunction Module FvwmThumbnail
[/code]
I expect you’ll want to fiddle with the scaling factors and the hotkey definitinon. It works on my box, let me know if you still have problems

@VoiDeR: pm me with an email addy and I’ll post you a copy of the wall. Did the imagemagik rebuild sort you out?

I no sooner posted the last update than it occurred to me that this module could sensibly offer screenshot and windowshot calls. So I added them:

Key S A 4 SendToModule FvwmThumbnail ScreenShot $[HOME]/screenshot.png Key W A 4 SendToModule FvwmThumbnail WinShot $[w.id] $[HOME]/winshot.png
Updated module in the same place as before.

I too have Image Magick + Perl problems, so I haven’t been able to test this module. It sounds like a great complement to something I’ve worked out. It takes thumbnails named according to $[w.id] and builds a windowlist-like menu. I have an FvwmEvent to take the screenshots, this would probably work better. I plan on redoing this later (ca. June) as a Perl module or a patch to the current WinList module, unless someone else wants to.

################################################################################
#
# SCREENSHOT WINDOWLIST
#
################################################################################

################################################################################
# NOTES
################################################################################

# this file contains code to screen capture individual windows, shrink the image to a thumbnail
# and build a windowlist-like menu with the screenshots

# the idea is based on taviso's FvwmExpose, and the code is derived from that

# requires a png image that is 128x96 solid transparent 
# must be named $SCREENSHOT_ICONDIR/template.png
# also needs ImageMagick convert and composite

# to do: 
# make a menu for all windows, sorted by desk
# filter out characters such as ',",`,%,*, etc. from window names
#   this is quite tricky and may require an external script


################################################################################
# INITIALIZATION
################################################################################

SetEnv SCREENSHOT_ICONDIR $[FVWM_USERDIR]/cache/screenshot_icons

MenuStyle * SelectOnRelease Super_L


################################################################################
# FUNCTIONS
################################################################################

# stripped down version of taviso's Thumbnail function
# makes a screenshot icon of the focused window
DestroyFunc ScreenShotThumbnail
AddToFunc ScreenShotThumbnail
+ I     ThisWindow (Visible) Exec \
        xwd -silent -id $[w.id] | \
        convert -scale 126x94 -frame 1x1 -mattecolor black -quality 0 xwd:- png:$[SCREENSHOT_ICONDIR]/$[w.id].png >&/dev/null ; \
        composite -gravity center $[SCREENSHOT_ICONDIR]/$[w.id].png $[SCREENSHOT_ICONDIR]/template.png $[SCREENSHOT_ICONDIR]/$[w.id].png >&/dev/null &


## stripped down version of taviso's FvwmExpose function
## generates a windowlist-like menu of all windows on the current desk,
## using screenshot thumbnails as icons
#DestroyFunc ShowScreenShotMenu
#AddToFunc ShowScreenShotMenu
#+ I     DestroyMenu ScreenShotMenu
#+ I     PipeRead 'echo AddToMenu ScreenShotMenu \\"\\$\[desk.name$[desk.n]\]\\" Title'
#+ I     AddToMenu ScreenShotMenu DynamicPopDownAction DestroyMenu ScreenShotMenu
#+ I     AddToMenu ScreenShotMenu "%mini.windows.xpm% W I N D O W   L I S T" WindowList
#+ I     All (!Iconic, !Shaded, CurrentDesk, AcceptsFocus) \
#        AddToMenu ScreenShotMenu "%$[SCREENSHOT_ICONDIR]/$[w.id].png%$[w.name]" \
#        WindowId $[w.id] WindowListFunc
#+ I     All (Iconic, !Shaded, CurrentDesk, AcceptsFocus) \
#        AddToMenu ScreenShotMenu "%$[SCREENSHOT_ICONDIR]/$[w.id].png%($[w.name])" \
#        WindowId $[w.id] WindowListFunc
#+ I     Any (!Shaded, CurrentDesk, AcceptsFocus) Menu ScreenShotMenu
#+ I     TestRc (False) WindowList

# same as above, but truncates the window name if it's too long
# stripped down version of taviso's FvwmExpose function
# generates a windowlist-like menu of all windows on the current desk,
# using screenshot thumbnails as icons
DestroyFunc ShowScreenShotMenu
AddToFunc ShowScreenShotMenu
# if there are no windows on the current desk, do a winlist for all desks
+ I     None (!Shaded, CurrentDesk, AcceptsFocus) WindowList SelectOnRelease Super_L
+ I     TestRc (Match) Break
# rebuild the screen shot menu
+ I     DestroyMenu ScreenShotMenu
+ I     PipeRead 'echo AddToMenu ScreenShotMenu \\"\\$\[desk.name$[desk.n]\]\\" Title'
+ I     AddToMenu ScreenShotMenu DynamicPopDownAction DestroyMenu ScreenShotMenu
# this will add a menu entry for each non-iconic window
# the window name is shortened if longer than 50 chars
# set -f turns off filename expansion (causes problems when a name has a '*')
+ I     All (!Iconic, !Shaded, CurrentDesk, AcceptsFocus) PipeRead ' \
        set -f ; \
        name="$[w.name]" ; \
        if [[ `echo "${name}" | wc -c` -gt 50 ]] ; \
        then name=`echo "${name}" | sed -e "s%^\\(.\\{27\\}\\).*\\(.\\{20\\}\\)$%\\1...\\2%g"` ; \
        fi ; \
        echo AddToMenu ScreenShotMenu \\"%$[SCREENSHOT_ICONDIR]/$[w.id].png%${name}\\" \
            WindowId $[w.id] WindowListFunc'
# this does the same for all iconic windows
# the only difference is that the name now has parens around it (and the iconic windows go at the end of the menu)
+ I     All (Iconic, !Shaded, CurrentDesk, AcceptsFocus) PipeRead ' \
        set -f ; \
        name="$[w.name]" ; \
        if [[ `echo "${name}" | wc -c` -gt 50 ]] ; \
        then name=`echo "${name}" | sed -e "s%^\\(.\\{27\\}\\).*\\(.\\{20\\}\\)$%\\1...\\2%g"` ; \
        fi ; \
        echo AddToMenu ScreenShotMenu \\"%$[SCREENSHOT_ICONDIR]/$[w.id].png%\\(${name}\\)\\" \
            WindowId $[w.id] WindowListFunc'
# and a window list so all windows are accessible
+ I     AddToMenu ScreenShotMenu "%mini.windows.xpm% W I N D O W   L I S T " WindowList SelectOnRelease Super_L
# show the menu
+ I     Menu ScreenShotMenu


################################################################################
# MODULES
################################################################################

# an FvwmEvent to screenshot a window every time it is raised
DestroyModuleConfig FvwmEvent FvwmEventThumbnail
*FvwmEventThumbnail: Cmd
*FvwmEventThumbnail: raise_window   ScreenShotThumbnail
*FvwmEventThumbnail: add_window     ScreenShotThumbnail
*FvwmEventThumbnail: focus_change   ScreenShotThumbnail
#*FvwmEventThumbnail: map            ScreenShotThumbnail


################################################################################
# BINDINGS
################################################################################

Mouse   2       R       A       ShowScreenShotMenu
Key     Tab     A       4       NoWindow ShowScreenShotMenu


################################################################################
# STARTUP
################################################################################

KillModule FvwmEvent FvwmEventThumbnail
Module FvwmEvent FvwmEventThumbnail

Exec exec rm -f $[SCREENSHOT_ICONDIR]/0x*.png

A screenshot resides here:
http://www.lynucs.org/index.php?screen_type=1&screen_id=5369491464251e409de32d&m=screen

The screenshot is outdated, I took it before I put the code in to shrink long names. The function used to generate the menu in the screenshot is commented out.

VoiDeR reports that rebuilding ImageMagick sorted out his PerlMagick problems, so it sounds like a bug in one particular version. Unless you have a different error, anyway.

From the sound of it you should be able to do what you want with FvwmThumbnail on its own: you can generate a scale class of icons sized for the winlist, and then use the Apply command to set them before invoking the wndow list. Then add another apply to the window list function itself to restore them to something more suitable for everyday use.

Talking about which events trigger thumnailing reminded me that I’ve been meaning to add a way to choose which events trigger thumnailing and icon file deletion. So I’ve added a couple of config options: GenerateOn and DeleteOn:

*FvwmThumbnail: GenerateOn raise_window *FvwmThumbnail: DeleteOn destroy_window windowshade iconify

A lot of bugfixing and general tightening up of code as well.

Latest version is here

It is quite possible that I am going crazy but nothing is working for me right now.

I do have a question about the key binding. what is the 4S portion of your key invocation?

My understanding is that is works like this:

Key Keyname Context Modifier Function. I am lost as to the 4S

The ‘4’ details the modifier number as setup by xmodmap. Here’s a typical output:

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Control_R (0x6d)
mod1        Meta_L (0x40),  Alt_R (0x71)
mod2        Num_Lock (0x4d)
mod3        Super_L (0x73)
mod4        Menu (0x75)
mod5        Scroll_Lock (0x4e)

Hence, one could replace the ‘4’ with the word ‘menu’ (as it is listed as such in the modifier output from above) and the same key would be used.

– Thomas Adam

Thanks ThomasAdam,

I think I was overthinking it and got myself confused. Which is not hard for me to do :blush:

I have never used the “Windows” key and I think that is what got me all turned around.

Sorry about that - I’ve been using that for long enough that I forget it’s not a standard mapping. Is it working other than that? I’d like this to be as robust as possible

If you want it to be robust, then assuming that any keys other than the standard modifiers are defined is a bad thing. You can be assured (as it is part of the Xserver) that capslock, scrollock, and numlock, along with CTRL and ALT will be mapped. But for things like the windows key, you’ll have to check it via the output of ‘xmodmap’.

– Thomas Adam

The module doesn’t (or shouldn’t) make any assumptions about key mappings - just my hastily cut-and-pasted posts on the subject. I’ll fix them now.

No the key bindings are perfect and work just fine! Actually they worked all along but I was using the wrong combinations.

Now , I need to work on FvwmThumnail

Thanks for the help

/usr/bin/perl: error while loading shared libraries: /usr/lib/perl5/vendor_perl/5.8.6/i686-linux/auto/Image/Magick/Magick.so: undefined symbol: InitializeMagick

Running gentoo with perl-5.8.6-r4, imagemagick-6.2.2.0 and fvwm-2.5.12