27 |
# import (part of ImageMagick package) |
# import (part of ImageMagick package) |
28 |
# |
# |
29 |
# It will create snapshot of following size |
# It will create snapshot of following size |
30 |
W=800 |
W=1024 |
31 |
H=800 |
H=768 |
32 |
|
|
33 |
# and then resize it to |
# and then resize it to (comment out to disable) |
34 |
RESIZE=200x |
#RESIZE=200x |
35 |
|
|
36 |
# some configurable paths |
# some configurable paths |
37 |
BROWSER=mozilla-firefox |
BROWSER=mozilla-firefox |
38 |
XSERVER=vncserver |
XSERVER=vncserver |
39 |
|
XWIT=xwit |
40 |
URL=$1 |
URL=$1 |
41 |
FILE=${2:-screenshot.jpg} |
FILE=${2:-screenshot.jpg} |
42 |
|
|
43 |
FRAMESET="`mktemp`.html" |
FRAMESET="`mktemp`.html" |
44 |
PORT=8888 |
PORT=8888 |
45 |
|
|
46 |
|
if [ -z "$URL" ] ; then |
47 |
|
echo "usage: $0 http://url.to.capture [screenshot.jpg]" |
48 |
|
exit 1 |
49 |
|
fi |
50 |
|
|
51 |
|
if [ -z "`which $XWIT`" ] ; then |
52 |
|
echo "$0 really need xwit to operate. please install it." |
53 |
|
exit 1 |
54 |
|
fi |
55 |
|
|
56 |
echo -n "testing URL $URL " |
echo -n "testing URL $URL " |
57 |
if HEAD $URL >/dev/null ; then |
if HEAD $URL >/dev/null ; then |
58 |
echo "ok" |
echo "ok" |
110 |
exit 1 |
exit 1 |
111 |
fi |
fi |
112 |
|
|
113 |
|
# move window to foreground |
114 |
|
$XWIT -display $DISPLAY -id $WINDOW_ID -pop |
115 |
|
|
116 |
echo "resizing window $WINDOW_ID to maximum size" |
echo "resizing window $WINDOW_ID to maximum size" |
117 |
xwit -display $DISPLAY -id $WINDOW_ID -resize $W $H |
$XWIT -display $DISPLAY -id $WINDOW_ID -move 0 0 |
118 |
|
$XWIT -display $DISPLAY -id $WINDOW_ID -resize $W $H |
119 |
|
|
120 |
|
|
121 |
echo -n "wating for browser ping..." |
echo -n "wating for browser ping..." |
135 |
fi |
fi |
136 |
|
|
137 |
echo "saving window $DUMP_ID to $FILE" |
echo "saving window $DUMP_ID to $FILE" |
138 |
import -window $DUMP_ID -geometry $RESIZE $FILE |
if [ ! -z "$RESIZE" ] ; then |
139 |
|
RESIZE="-geometry $RESIZE" |
140 |
|
fi |
141 |
|
import -window $DUMP_ID $RESIZE $FILE |
142 |
|
|
143 |
kill_vnc |
kill_vnc |
144 |
|
|