/usr/games/grab_cgoban is in cgoban 1.9.14-16.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | #! /bin/bash
#
# grab_cgoban save.gif
#
# Look for a cgoban window, grab the displayed GO board and save it
# as a gif file.
#
# Anthony Thyssen <anthony@cit.gu.edu.au> 24 October 1995
#
# The location of board in CGoban Window
# X=15 Y=78 S=393 # perfect fit -- wood only
# X=14 Y=77 S=395 # one pixel more (testing)
X=8 Y=70 S=410 # green background frame
TMP=/tmp/grab_cgoban.$$
trap "rm -f $TMP; exit 0" 0
if [ $# -ne 1 ]; then
echo >&2 "Usage: grab_cgoban save.gif"
exit;
fi
# get the windows ID - ignore the Control or tools window if present
window=`xwininfo -tree -root |
sed -n '/"CGoban"/!d; /"CGoban /d; s/^ *\(0x[^ ]*\).*/\1/p'`
# How many boards did we find
num=`echo $window | wc -w`
if [ $num -lt 1 ]; then
echo >&2 "No CGoban Board found! - aborting"
exit 10
fi
if [ $num -gt 1 ]; then
echo >&2 "Multiple CGoban Boards found! - aborting"
exit 10
fi
# Figure out image filters to use!
case "`type convert`" in
*'not found'*)
case "`type ppmtogif`" in
*'not found'*)
case "`type pnmtogif`" in
*'not found'*)
FILTER=XWD ;;
*) FILTER=PBMPLUS_OLD ;;
esac ;;
*) FILTER=PBMPLUS ;;
esac ;;
*) FILTER=IMAGEMAGICK ;;
esac
# for debugging
#echo "filtering image with $FILTER"
# grab the image and filter appropriately
case "$FILTER" in
IMAGEMAGICK)
# note ImageMagick can output to given files suffix
# in fact it relies on a suffix to the file type
xwd -id $window |
convert -crop ${S}x${S}+${X}+${Y} - $1
;;
PBMPLUS)
xwd -id $window |
xwdtopnm 2>/dev/null |
pnmcut $X $Y $S $S |
ppmtogif 2>/dev/null > $1
;;
PBMPLUS_OLD)
xwd -id $window |
xwdtopnm 2>/dev/null |
pnmcut $X $Y $S $S |
pnmtogif 2>/dev/null > $1
;;
XWD)
echo >&2 "WARNING: unable to find a image filter package"
echo >&2 "Dumping a XWD image to \"$1.xwd\" instead of GIF format"
xwd -id $window > $1.xwd
;;
esac
# for Debugging
#xv $1 &
|