Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
#!/bin/bash
# This file:
#   http://angg.twu.net/bin/Xscreenshot.html
#   http://angg.twu.net/bin/Xscreenshot
#    (find-angg        "bin/Xscreenshot")
# See: (find-angg      "bin/Xscreenshot-rect")
# Test:
#   (find-sh0 "sleep 2; Xscreenshot")
#   (find-fline "/tmp/screenshots/")
#
# It's better to use this:
# (eev "sleep 2; xwd -root -out /tmp/ss.xwd; convert /tmp/ss.xwd /tmp/ss.png")
# (find-fline "/tmp/ss.png")
#   (find-efunction 'Xscreenshot)

# (find-angg ".fvwm/.fvwm2rc" "DebianMenu")
# (find-angg ".zshrc" "myincr")
# (find-man "1 convert")
# (find-man "1 xwd")
# (find-man "1 xwd" "-root ")
# (find-man "1 xwd" "-nobdrs ")
# (find-man "1 xwd" "-frame ")
# A trick to take a full-screen screenshot after 10 seconds:
#   (find-sh0 "sleep 10; Xscreenshot -root")
# Ooops, I broke the part that used "$*"...
#
# Tests:
#   (find-sh0 "rm -v /tmp/screenshots/n")
#   (find-sh0 "Xscreenshot")
#   (find-sh0 "Xscreenshot")
#   (find-sh0 "Xscreenshot last")
#   (find-sh0 "cat /tmp/screenshots/n")
#   (find-sh0 "echo /tmp/screenshots/$(cat /tmp/screenshots/n).png")
#   (find-sh0 "printf /tmp/screenshots/ss%02d.png 9")
#   (find-fline "/tmp/screenshots/")
#   (find-fline "/tmp/screenshots/n")

DIR=/tmp/screenshots
FMT=/tmp/screenshots/ss%02d.png
NFILE=/tmp/screenshots/n

mkdir -p $DIR
cd       $DIR || { echo "can't cd to $DIR"; exit 1; }
if [ ! -e $NFILE ]; then 
  echo 0 > $NFILE
fi

   N=$(cat $NFILE)
NEWN=$[$N+1]

case "_$1_" in
   _last_)  printf $FMT $N;;
       __)  xwd | convert - $(printf $FMT $NEWN); echo $NEWN > $NFILE;;
  _named_)  xwd | convert - $2;;
        *)  echo ERROR;;
esac