#!/bin/wish -w # Screen grab # # # readimage() cannot cope with image files not on 0,0 origin # We have to use crop to move them otherwise they are clipped # out of their clip rectangle # seems a bit of a naff way of doing things # # Dont use execfs to resize images so it will work on stock systems # proc fixedimage {w} { set fd [openfd $w 0] set data [readfd $fd 66] closefd $fd set x [index $data 1] set y [index $data 2] if [expr ($x == 0) && ($y == 0) ] { system resize -x [index $res 0] -y [index $res 1] '$w' >/tmp/__new__ } { system resize -x [index $res 0] -y [index $res 1] '$w' | crop -t [expr 0 - $x] [expr 0 - $y] >/tmp/__new__ } image /tmp/__new__ } set window [split [system ls {/dev/wsys/[0-9]*/window}] "\n"] set r 1 set c 1 set res {128 80} frame .top -side top -anchor left -fill both -expand 1 button .top.q -text QUIT -cmd evQuit -side bottom -anchor SE frame .top.r$r -side top -fill BOTH -anchor NW -expand 1 set window [slice $window 0 20] foreach $window { if not [streq $i {}] { set l [repstr $i window label] set ctl [repstr $i window wctl] set img [fixedimage ${i}] group .top.r${r}.g$c -fill y -width 140 -side left -anchor NW -expand FIXEDX button .top.r${r}.g${c}.img -image $img -width 128 -height 64 -side top -cmd "top $ctl" label .top.r${r}.g${c}.lbl -text "[system cat $l]" -side top inc c if [streq $c 5] { set c 1 inc r frame .top.r${r} -side top -fill BOTH -anchor NW -expand 1 } } } proc top {w id btn} { if [streq $btn 4] { set global _top $w evQuit } store $w top sleep 500 store $w bottom } store /dev/label "WinFinder" tktoplevel .top eventloop 1000 if not [streq $_top {}] { store $_top top sleep 50 store $_top current sleep 50 }