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

From: Tristan RAMBO Savatier <[email-masked]>
Date: Sun, 29 Sep 1996 01:32:15 -0700

Subject: need help with screen-shots under X11
From: Tristan RAMBO Savatier <[email-masked]>
Date: Sun, 29 Sep 1996 01:31:25 -0700
Newsgroups: comp.windows.x.apps

Does anyone know how to capture a screen-shot under X-Windows ?

I am using FVWM (under Linux).  Is there a way to ask the X server
(in this case XFree86) or the window manager (fvwm) to take a snapshot
of the screen and save it as an image ? I looked at the manual of FVWM
but couldn't find the answer.

Please copy the answer to my email address! Thanks!

Regards,

-- Tristan Savatier (mailto:[email-masked] - http://www.mpeg.org)
   "My karma ran over my dogma"

--
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 [email-masked].
To report problems, send mail to [email-masked].

---

From: Christopher Greenup <[email-masked]>
Date: Sun, 29 Sep 1996 04:09:15 -0500 (CDT)

>    "My karma ran over my dogma"

xwd and xv are two programs that I know of that will allow you to `dump` 
or `grab` the screen, respectively.  xwd is strictly command line, 
whereas xv is point and click.

        -+*%$%*+-+*%$%*+-+*%$%*+-+*%$%*+-+*%$%*+-+*%$%*+-+*%$%*+-
        ][   Christopher Greenup   ]|[  Apex Internet Services ][
        ][     [email-masked]      ]|[   http://www.apex.net   ][
        -+*%$%*+-+*%$%*+-+*%$%*+-+*%$%*+-+*%$%*+-+*%$%*+-+*%$%*+-

---

From: Richard Lister <[email-masked]>
Date: Sun, 29 Sep 1996 13:24:34 +0100

From: Tristan RAMBO Savatier <[email-masked]>
Subject: FVWM: [Fwd: need help with screen-shots under X11]
Date: Sun, 29 Sep 1996 01:32:15 -0700

> but couldn't find the answer.

This is an X server issue, not a wm issue.

You can do 'xwd -root' or use the grab function of xv, and I think
there are more utilities knocking around that do much the same thing. 

Ric

---

From: Martin Kraemer <[email-masked]>
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@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 "$@" >&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 "$@" >&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 |  <[email-masked]>  |      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 [email-masked].
To report problems, send mail to [email-masked].

---

From: [email-masked] (Albrecht Kadlec)
Date: Mon, 30 Sep 96 15:04:56 +0100

>>>>> Martin Kraemer writes:

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

It's only useful if the caller of the function was able to supply a window
parameter, which is not the case, if a menu is brought up from the root.

albrecht
-- 
It's getting late in the game to show any pride or shame
We burn a little brighter now, burn a little brighter now
						-- Marillion
--
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 [email-masked].
To report problems, send mail to [email-masked].