#!/bin/bash
######################################################################
#
# printer-status -- change the LCD readout on your HP LaserJet
#
# dsandler@dsandler.org - April 13, 2000
#
######################################################################

WIDTH=16
BARS="+------------------+"
PRINTER=$1

if [ $# != 3 ]; then
  echo "usage: $0 <printer> <line1> <line2>"
  exit 1
fi

linea=`echo "$2" | tr 'a-z' 'A-Z'`
lineb=`echo "$3" | tr 'a-z' 'A-Z'`
msg=`printf "%-${WIDTH}.${WIDTH}s%-${WIDTH}.${WIDTH}s" "$linea" "$lineb"`


echo "Printer: $1"
echo $BARS
printf "| %-${WIDTH}.${WIDTH}s |\n| %-${WIDTH}.${WIDTH}s |\n" "$linea" "$lineb"
echo $BARS

printf "Set the display of $1 ? "
read go

if [ `echo $go | grep -ci ^y` = "1" ]; then
  echo -e "\033%-12345X@PJL RDYMSG DISPLAY=\"$msg\"" | \
      lpr -l -P$PRINTER
  echo "lpr result code: $?"
  echo "done."
else
  echo "aborting."
fi

