duplex.0.5 Duplex Printing Emulator Usage: duplex "" "" |<-> are parameters passed to lp to control printing the first side of all the pages are parameters passed to lp to control printing the second side of all the pages is the path of the file to print. If <-> is specified, standard input is used. Note: lp parameters contain embedded whitespace and must be quoted as one string. Usage for optional dplx script: dplx [-opt ""] [|<->] -opt, if present, specifies that the following argument contains additional common lp parameters are additional parameters to pass to lp for both printing passes is, optionally, the path of the file to print. If <-> or no filename parameter is specified, standard input is used. Note: lp parameters contain embedded whitespace and must be quoted as one string. For convenience, the pass-one and pass-two specific lp parameters are hard coded in dplx and should be modified to reflect the needs of your printer. Description: duplex is a shell program (sh) which emulates duplex printing (on both sides of the paper) for printers that do not support duplex printing in hardware. It is intended for use with printers which are (at least temporarily) dedicated to a workstation. A companion shell script, dplx has been provided which invokes duplex with parameters set up for an HP Deskjet printer. When invoked, duplex prints the single file to be printed in two passes. The first pass prints one side of each page and the second pass prints the other side of each page. To facilitate this, as soon as the first pass is sent to the printer, a dialog box is displayed, using the Xdialog package (requires X, GTK) which prompts the user to wait for the first pass to complete printing (the script currently can not detect this). Then, the user must remove the pages, rotate them appropriately (180 degrees, horizontally for a Deskjet), and reinsert them in the input paper tray and click the "Yes" button (or press Enter) to print the second pass. dplx is currently set up to call duplex such that the odd numbered pages are printed in reverse and then the even pages are printed forward. This causes the top page of the stack printed from pass one to be the first page of the file which is usually easiest to recognize. After the first pass is sent to the printer, the user may click the "No" button to eliminate printing the second pass. duplex cannot currently determine the number of pages to be printed. If the total nubmber of pages to be printed is odd, the last page of the first pass should not be reinserted because it will remain in the in tray upon completion and potentially become part of the next print job. Because dplx accepts standard input, it may be used wherever lp would be used such as in application printer configurations (e.g. browsers, word processors, etc.). Examples: dplx myfile prints myfile in duplex cat myfile | dplx prints myfile in duplex dplx -opt "-o page-ranges=1-4,7,9-12" myfile prints selected pages from myfile in duplex Installation: dplx and duplex require the Xdialog package (e.g. Xdialog-2.0.6-2mdk.i586.rpm) which requires X, GTK. Once that's installed, just put the scripts in a directory in your path such as ~/bin and make sure they are executable. Limitations: dplx/duplex cannot detect odd page counts and automatically eject the last page on the second pass. dplx/duplex cannot detect pass one printing completion, so it is up to the user to wait for it to complete and reinsert the pages before clicking Yes" to print the second pass. dplx/duplex splits one conceptual print job into two separate asynchronous jobs. This will only work gracefully with an idle printer, one print job at a time. Bugs: duplex will print a single page graphic file (e.g. .jpg) twice, once for each call to lp, if the user does not stop it by selecting "No". It works fine for single page text files. To do: Capture print job number from lp and wait till it's done to display the message box. Acknowledgements: Thanks to lp (CUPS) for doing all the hard work and to Till Kamppeter for Xpp which showed me it could be done at all. "I stand on the toes of giants." Joseph Pollock - JPmicrosystems - josephj AT buffnet.net