MATLAB: How does MATLAB choose the default printer on Unix/Linux machines

defaultlinuxMATLABprintersunix

How does MATLAB choose the default printer on Unix/Linux machines?
I would like to know how MATLAB determines the default printer, so I know what environment variables to change, or files to modify.

Best Answer

By default, MATLAB uses the printer specified in the 'cmd' variable output from PRINTOPT (if one is specified). If there isn't a printer specified in printopt.m, then the LPDEST and PRINTER environment variables are checked.
If the system print command specified in printopt.m contains 'lpr', then PRINTER is used; if it contains 'lp', then LPDEST is used. In both cases, if the first variable used is undefined, then the other will be used. The default printer will then be added to the beginning of the available printer list.
If both LPDEST and PRINTER are undefined, then MATLAB looks for the following files, in order:
$HOME/printers.conf
/etc/printers.conf
/etc/printcap
It will use the first valid file it finds, and begin processing the printer information it contains. The first printer whose name is preceded by 'lp' in the file will become the default printer. If none of the printers names are preceded by 'lp', then the first printer listed will become the default.