1#!/bin/sh 2# 3# Printer filter for postscript or plain text with output to a HP laserjet. 4# This requires two packages to be installed: 5# 6# /usr/pkgsrc/print/ghostscript 7# /usr/pkgsrc/print/enscript 8# 9# lp|ps|local line printer:\ 10# :sh:mx#0:sf:\ 11# :lp=/dev/lpt0:sd=/var/spool/output/lpd:lf=/var/log/lpd-errs:\ 12# :if=/usr/local/libexec/if-gs-ljet4: 13# 14# $DragonFly: src/share/examples/printing/if-gs-ljet4,v 1.1 2006/08/15 16:21:23 dillon Exp $ 15 16read first_line 17first_two_chars=`expr "$first_line" : '\(..\)'` 18 19if [ "$first_two_chars" = "%!" ]; then 20 # 21 # PostScript job, print it. 22 # 23 (echo "$first_line" && cat && exit 0) | \ 24 gs -q -sPAPERSIZE=letter -sDEVICE=ljet4 -sOutputFile=%stdout% - 25 # printf "\004" 26 exit 2 27else 28 # 29 # Plain text, convert it, then print it. 30 # 31 ( echo "$first_line"; cat ) | /usr/pkg/bin/enscript -G | \ 32 gs -q -sPAPERSIZE=letter -sDEVICE=ljet4 -sOutputFile=%stdout% - 33 # printf "\004" 34 exit 2 35fi 36