#!/bin/bash

# See if we have a filename on the command-line...
if test -z "$6"; then
TMPFILE=`mktemp`
cat >$TMPFILE
	ifile="$TMPFILE"
else
        ifile="$6"
fi
# try to figure out the dpi's...
DPI=`cat $PPD |grep -i "resolution " |tail -n 1|sed -e "s;\*Resolution.*dpi/;;" -e "s; DPI.*;;"`

ARGS="-D $DPI "
if test "$DPI" -gt "400"; then 
 ARGS="$ARGS -Z "
fi
echo INFO: Starting dvips. 1>&2
echo DEBUG: Running /usr/bin/dvips $ARGS -f \< "$ifile" 1>&2

exec /usr/bin/dvips $ARGS -f <"$ifile"
rm -f $TMPFILE