#!/usr/bin/perl -w # # nicelpr # # Print things, but only when the print queue is empty. # # -- Ed Avis, epa98@doc.ic.ac.uk, 2000-03-05 # use strict; use diagnostics; use Log::TraceMessages qw(t d); Log::TraceMessages::check_argv(); use LPQ; ######## # Configuration # # Name of command to use to print stuff. Things will be piped into # this command on standard input. # my $LPR = 'stapler2 | lpr'; # How often to check the print queue, in seconds my $DELAY = 10; ######## # End of configuration # @ARGV = ('-') if not @ARGV; t('\@ARGV=' . d(\@ARGV)); FILE: foreach my $file (@ARGV) { for (;;) { my ($printer, $jobs) = lpq(); t('$printer=' . d($printer)); t('$jobs=' . d($jobs)); if (scalar(@{$jobs}) == 0) { system "cat $file | $LPR"; next FILE; } sleep $DELAY; } }