startup={ action="PRINT Run this example from the command line
with -var printerlist to monitor additional printers
and/or -var defprinter to select a default printer.\n " }

!add printers here or use -var printerlist on the command line
var={ name=printerlist value="ps lw sparc tek" }
!default printer here or use -var defprinter on the command line
var={ name=defprinter value="ps" }

!menu with a typeable field to override it.
menubutton={ name=printermenu label="Printer list"
        value=$defprinter itemlist={ list=$printerlist } 
 	action="ASSIGN printer $(val)" 
 	action="ASSIGN checkqueue $(val)" 
}
field={ name=printer value=$defprinter 
	  action="ASSIGN printermenu $(val) "
	  action="ASSIGN checkqueue $(val) "
}

! A single colum list that is the output of lpq
! selecting an item sets the jobnumber in the "jobnum" field (3rd field)
list={ name=queue 
       itemlist={ list=`lpq -P$(printer)` separator="\n"} 
       columns=1 height=150 width=500 font=fixed
       action="ASSIGN jobnum `echo $val | awk '{print $$3}' `" 
}

! assigning to  this variable updates the job list
var={ name=checkqueue value=" " action="SET queue list `lpq -P$(printer)`" }

! every 5 secs update the list
timer={ interval=5 action="ASSIGN checkqueue $(printer) " }

! a field to hold the selected job number
field={ name=jobnum value=" " }

! a button to remove the job, it calls up a yes-no panel to check
button={ label=REMOVE
  test={ 
    condition="xtpanel -var text 'really remove $jobnum ?' -file examples/script/yes-no"
    true={ action="lprm -P$(printer) $jobnum" }
  }
}

button={ name=QUIT action=QUIT }
