Re: FVWM: [Fwd: need help with screen-shots under X11]

From: Martin Kraemer <Martin.Kraemer_at_mch.sni.de>
Date: Mon, 30 Sep 1996 09:50:09 +0100 (MET)

Hello Tristan,

I have two ways of getting Screenshots. One is "directly to printer" and
is done as an additional "Print" command in the window's pulldown menu
(the Hardcopy script tries to detect if the caught window has portrait or
landscape format and rotates it by 90 degrees if necessary):

#### from: ~/.fvwm2rc95, works on any recent fvwm-2
AddToMenu "Window-Ops2" "&Restore" Iconify -1
+ "&Move" Move-or-Raise
+ "&Size" Resize-or-Raise
+ "&Lower" Lower
+ "Mi&nimize" Iconify 1
+ "Ma&ximize" Maximize 100 100
+ "&Print" PrintFunction $w
+ "" Nop
+ "&Kill" Destroy
+ "&Close Alt+F4" Delete

# Private: Print current window
AddToFunc PrintFunction "I" Raise
+ "I" Exec /home/martin/BIN/Hardcopy $w $1

...and the other is used with the Ctrl-[Print] key (it doesn't actually
print but invokes xv to pre-view the currently active window's snapshot
for saving or printing):

#### from: ~/.fvwm2rc95, works on any recent fvwm-2
Key Print WIFST C Exec /home/martin/BIN/xvHardCopy $w $1

<<Note: I've tried fiddling about with the $w parameter, but somehow it
works only in special places... Gotta re-read the man page for this. The
way I did it here works - even if it's incorrect>>

Then there are the two scripts Hardcopy and xvHardCopy which get the
window (including frame) using the ImageMagick "import" function, the
first one is rotating automatically if necessary.

<<Note: You'll have to adapt the paths and the lp/lpr printing parameters
as this is for the non-Linux system I'm using here>>

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: /home/martin/BIN/Hardcopy /home/martin/BIN/xvHardCopy
# Wrapped by martin_at_deejai on Mon Sep 30 09:41:24 1996
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f '/home/martin/BIN/Hardcopy' -a "${1}" != "-c" ; then
  echo shar: Will not clobber existing file \"'/home/martin/BIN/Hardcopy'\"
else
echo shar: Extracting \"'/home/martin/BIN/Hardcopy'\" \(2302 characters\)
sed "s/^X//" >'/home/martin/BIN/Hardcopy' <<'END_OF_FILE'
X#!/bin/sh
X# $Id: Hardcopy,v 1.4 1996/06/03 12:03:12 deejai!martin Exp deejai!martin $
XPATH=$PATH:/usr/bin/X11:/home/martin/BIN; export PATH
X
XError(){
X echo '$Id: Hardcopy,v 1.4 1996/06/03 12:03:12 deejai!martin Exp deejai!martin $' >&2
X echo "$_at_" >&2
X exit 1
X}
X
Xcase "$WINDOWID:$1" in
X ":") # neither WINDOWID nor Parameter given
X xmessage -timeout 30 -file - <<. &
Xxwininfo ==> Please select the window about which you
X ==> would like information by clicking the
X ==> mouse in that window.
X (...Or click THIS window to abort Hardcopy.)
X.
X KID=$!
X KIDWIN=`xwininfo -name xmessage 2>&1 | grep 'Window id: ' | awk '{ print $5; }'`
X WINDOWID=`xwininfo 2>&1 | grep 'Window id: ' | awk '{ print $5; }'`
X kill $KID
X case "$WINDOWID:$1" in
X 0x27:"")
X Error "Hardcopy aborted (clicked on root window)"
X ;;
X $KIDWIN:"")
X Error "Hardcopy aborted (clicked on xmessage window)"
X ;;
X ":") # neither WINDOWID nor Parameter given
X Error Specify '$WINDOWID' or a window id, please.
X ;;
X esac;;
X *:) ;;
X *) WINDOWID=$1;;
Xesac
X
X# Sometimes popping is unwanted...
X#xwit -pop -id $WINDOWID || Error Invalid Window Id $WINDOWID
X
X# Berechnen von Landscape oder Portrait:
Xset -- `xwininfo -id $WINDOWID | grep Width:` ; wid=$3
Xset -- `xwininfo -id $WINDOWID | grep Height:` ; hite=$3
X[ $wid -gt $hite ] && rotate="-rotate 90" || rotate=""
X
X# Wir verwenden nicht den $WINDOWID selbst, sondern 2 Stufen hoeher.
X# Dadurch bekommen wir auch den Rahmen mit drauf.
X# xwininfo sagt uns, wer der Vater von $WINDOWID ist.
X
X# Zur Sicherheit pruefen wir noch, ob der Vater das Rootfenster ist....
Xset -- `xwininfo -root | grep "Window id:"`
X[ "$5" = "" ] && Error Cannot access display $DISPLAY
Xroot=$5
X
Xset -- `xwininfo -id $WINDOWID -tree | grep Parent`
X[ "$2" = "Parent" ] || Error Invalid Window ID $WINDOWID
X[ "$5" = "$root" ] && Error Window ID $WINDOWID is not a normal window
X
Xset -- `xwininfo -id $5 -tree | grep Parent`
X[ "$2" = "Parent" ] || Error Invalid Window ID $WINDOWID
X[ "$5" = "$root" ] && Error Window ID $WINDOWID is not a normal window
X
XWIN=$5
X
X#XtoPS $rotate -frame -border -window $WIN - | /bin/lp -d POST -t Win=$WINDOWID
X/mx3_54/local/bin/import $rotate -descend -frame -border -window $WIN - | /bin/lp -d POST -t Win=$WINDOWID
END_OF_FILE
if test 2302 -ne `wc -c <'/home/martin/BIN/Hardcopy'`; then
    echo shar: \"'/home/martin/BIN/Hardcopy'\" unpacked with wrong size!
fi
chmod +x '/home/martin/BIN/Hardcopy'
# end of '/home/martin/BIN/Hardcopy'
fi
if test -f '/home/martin/BIN/xvHardCopy' -a "${1}" != "-c" ; then
  echo shar: Will not clobber existing file \"'/home/martin/BIN/xvHardCopy'\"
else
echo shar: Extracting \"'/home/martin/BIN/xvHardCopy'\" \(2239 characters\)
sed "s/^X//" >'/home/martin/BIN/xvHardCopy' <<'END_OF_FILE'
X#!/bin/sh
X# $Id: Hardcopy,v 1.4 1996/06/03 12:03:12 deejai!martin Exp deejai!martin $
XPATH=$PATH:/usr/bin/X11:/home/martin/BIN; export PATH
X
XError(){
X echo '$Id: Hardcopy,v 1.4 1996/06/03 12:03:12 deejai!martin Exp deejai!martin $' >&2
X echo "$_at_" >&2
X exit 1
X}
X
Xcase "$WINDOWID:$1" in
X ":") # neither WINDOWID nor Parameter given
X xmessage -timeout 30 -file - <<. &
Xxwininfo ==> Please select the window about which you
X ==> would like information by clicking the
X ==> mouse in that window.
X (...Or click THIS window to abort Hardcopy.)
X.
X KID=$!
X KIDWIN=`xwininfo -name xmessage 2>&1 | grep 'Window id: ' | awk '{ print $5; }'`
X WINDOWID=`xwininfo 2>&1 | grep 'Window id: ' | awk '{ print $5; }'`
X kill $KID
X case "$WINDOWID:$1" in
X 0x27:"")
X Error "Hardcopy aborted (clicked on root window)"
X ;;
X $KIDWIN:"")
X Error "Hardcopy aborted (clicked on xmessage window)"
X ;;
X ":") # neither WINDOWID nor Parameter given
X Error Specify '$WINDOWID' or a window id, please.
X ;;
X esac;;
X *:) ;;
X *) WINDOWID=$1;;
Xesac
X
X# Sometimes popping is unwanted...
X#xwit -pop -id $WINDOWID || Error Invalid Window Id $WINDOWID
X
X# Berechnen von Landscape oder Portrait:
Xrotate=""
X#set -- `xwininfo -id $WINDOWID | grep Width:` ; wid=$3
X#set -- `xwininfo -id $WINDOWID | grep Height:` ; hite=$3
X#[ $wid -gt $hite ] && rotate="-rotate 90" || rotate=""
X
X# Wir verwenden nicht den $WINDOWID selbst, sondern 2 Stufen hoeher.
X# Dadurch bekommen wir auch den Rahmen mit drauf.
X# xwininfo sagt uns, wer der Vater von $WINDOWID ist.
X
X# Zur Sicherheit pruefen wir noch, ob der Vater das Rootfenster ist....
Xset -- `xwininfo -root | grep "Window id:"`
X[ "$5" = "" ] && Error Cannot access display $DISPLAY
Xroot=$5
X
Xset -- `xwininfo -id $WINDOWID -tree | grep Parent`
X[ "$2" = "Parent" ] || Error Invalid Window ID $WINDOWID
X[ "$5" = "$root" ] && Error Window ID $WINDOWID is not a normal window
X
Xset -- `xwininfo -id $5 -tree | grep Parent`
X[ "$2" = "Parent" ] || Error Invalid Window ID $WINDOWID
X[ "$5" = "$root" ] && Error Window ID $WINDOWID is not a normal window
X
XWIN=$5
X
X#/mx3_54/local/bin/import $rotate -descend -frame -border -window $WIN gif:- | xv -
Xxwd -frame -id $WIN | xv -
END_OF_FILE
if test 2239 -ne `wc -c <'/home/martin/BIN/xvHardCopy'`; then
    echo shar: \"'/home/martin/BIN/xvHardCopy'\" unpacked with wrong size!
fi
chmod +x '/home/martin/BIN/xvHardCopy'
# end of '/home/martin/BIN/xvHardCopy'
fi
echo shar: End of shell archive.
exit 0


Hope this helps. It has proved to be a valuable tool for me!
    Martin
-- 
| S I E M E N S |  <Martin.Kraemer_at_mch.sni.de>  |      Siemens Nixdorf
| ------------- |   Voice: +49-89-636-46021     |  Informationssysteme AG
| N I X D O R F |   FAX:   +49-89-636-44994     |   81730 Munich, Germany
~~~~~~~~~~~~~~~~My opinions only, of course; pgp key available on request
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_hpc.uh.edu.
To report problems, send mail to fvwm-owner_at_hpc.uh.edu.
Received on Mon Sep 30 1996 - 03:50:30 BST

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:37:59 BST