summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xprintloop.sh7
-rwxr-xr-xtrigger.sh13
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
diff --git a/trigger.sh b/trigger.sh
index 9740048..4d6ad2c 100755
--- a/trigger.sh
+++ b/trigger.sh
@@ -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=$?