aboutsummarylogtreecommitdiffstats
path: root/foofilter
diff options
context:
space:
mode:
authorChris Severance2024-01-16 05:08:30 -0500
committerChris Severance2024-01-16 05:08:30 -0500
commit38248ace354b769d6aff5cab5b092224b89071b2 (patch)
tree929fdad44846511ca92d8c746f8d09dd62453d79 /foofilter
parent44160860d7d38faf0ce1cb8e99dfb52ed8d349fc (diff)
downloadaur-lprng.tar.gz
autu: Update to 3.9.0-1
Diffstat (limited to 'foofilter')
-rwxr-xr-xfoofilter61
1 files changed, 35 insertions, 26 deletions
diff --git a/foofilter b/foofilter
index 7fadd3d3e9a0..8fde8fe2a97a 100755
--- a/foofilter
+++ b/foofilter
@@ -2,34 +2,43 @@
#
# foofilter.sh -- Foomatic-rip-lprng is used as the print filter
#
-infile=/tmp/infile.$$
-tempfile=/tmp/tempfile.$$
+# Requires
+# poppler (xpdf): pdftops
+# foomatic-filters-lprng
+# enscript
+
+set -u
+
+# define temporary files
+infile="/tmp/infile.$$"
+tempfile="/tmp/tempfile.$$"
# replace example.ppd with the appropriate ppd file for your printer
-your_ppd=$example.ppd
-
-cat > $infile
-
-fileinfo=`file -b $infile`
-ascii=`echo $fileinfo | grep ASCII`
-pdf=`echo $fileinfo | grep PDF`
-ps=`echo $fileinfo | grep PostScript`
-
-if test "$ascii" != ''
-then
- enscript -M Letter -o - $infile > $tempfile
-elif test "$pdf" != ''
-then
- pdftops $infile - > $tempfile
-elif test "$ps" != ''
-then
- cat $infile > $tempfile
-else
- echo "Can not print file of type $fileinfo" | \
- enscript -M Letter -o - > $tempfile
-fi
+your_ppd="${example}.ppd"
+
+# choose your paper size
+PAPER='Letter'
+#PAPER='A4'
+
+# send the standard input to a temporary file
+cat > "${infile}"
+
+# figure out what type of file we are trying to print
+fileinfo="$(file -b "${infile}")"
+
+# take various actions depending on the type of file -- send
+# results to a temporary postscript file
+case "${fileinfo}" in
+*ASCII*) enscript -M "${PAPER}" -o - "${infile}" > "${tempfile}" ;;
+*PDF*) pdftops "${infile}" - > "${tempfile}" ;;
+*PostScript*) cat "${infile}" > "${tempfile}" ;;
+*)
+ echo "Cannot print file of type ${fileinfo}" | \
+ enscript -M "${PAPER}" -o - > "${tempfile}"
+ ;;
+esac
# foomatic-rip sends stuff to the standard output
-/usr/bin/foomatic-rip-lprng --lprng /etc/lprng/lpd/$your_ppd < $tempfile
+/usr/bin/foomatic-rip-lprng --lprng "/etc/lprng/lpd/${your_ppd}" < "${tempfile}"
-rm $infile $tempfile
+rm -f "${infile}" "${tempfile}"