diff options
-rwxr-xr-x | printloop.sh | 7 | ||||
-rwxr-xr-x | trigger.sh | 13 |
2 files changed, 15 insertions, 5 deletions
diff --git a/printloop.sh b/printloop.sh index 64c1e24..26a10f4 100755 --- a/printloop.sh +++ b/printloop.sh @@ -4,12 +4,11 @@ printer="/dev/labelprinter" queuedir=queue print_queue(){ - for job in $(ls -1 "$queuedir/new"); do - ./trigger.sh "$printer" "$queuedir" - done + ./trigger.sh "$printer" "$queuedir" } print_queue -while inotifywait --quiet --timeout 30 "$queuedir/new"; do +while true; do + inotifywait --quiet --timeout 30 "$queuedir/new" print_queue done @@ -6,7 +6,18 @@ printed_dir=$queue_dir/printed/ mkdir -p $printed_dir -for file in $(ls $queue_dir/new/* 2>/dev/null); do +printqueue(){ + ls $queue_dir/new/* 2>/dev/null +} + +queuedepth=$(printqueue | wc -l) + +if [ ! -c "$printer" ] ; then + printf "labelprinter is offline, there are %d jobs in queue\n" $queuedepth >&2 + exit 1 +fi + +for file in $(printqueue); do echo printing $file ./ql570/ql570 $printer $file status=$? |