#!/bin/sh

PATH=${PATH}:/usr/bin:/usr/local/bin

while [ "$1" != "-h" ] && [ "$1" != "" ]; do
  shift
done

hostname=localhost
if [ "$2" != "" ]; then
  hostname=$2
fi

LANG_FILE=%%LINUXBASE%%/usr/local/share/printui/i18n

export LANG=C
if [ -f ${LANG_FILE} ]; then
    export `grep LANG ${LANG_FILE}`
fi

resolution=600
papersize=a4
printer=BJ%%PRMODEL%%

GS="gs -q -r$resolution -dNOPROMPT -dSAFER \
      -sPAPERSIZE=$papersize -sDEVICE=bmp16m -sOutputFile=- -"
BJFILTER="bjfilter --display $hostname:0.0 \
--gui --model $printer --imageres $resolution --fit"
# --lgmon

psselect -r | bjcmd "${GS} | ${BJFILTER}"
