Change Default Printer from the Command Line in OS X
This came up the other day when I was talking to Nic. So I did a little digging.
When you change your default printer in Mac OS X, it makes a change in your /Library/Preferences/.GlobalPreferences.plist file. There is a key called DefaultDevice-prtr that indicates the default printer. That printer is specified by an integer that correlates to the device, which you can get from further down the plist file.
But you don't have to mess with this plist file if you want to change the default printer on a large group of remote machines. Mac OS X responds correctly to the standard CUPS commands. So you can just do the following:
lpstat -p will show you the printers available
lpstat -d will show you the current default printer
lpoptions -d printername will set the default to whichever printer you specify
This can also be helpful for scripting, say when you want to have a login script that changes the default printer for specific users who aren't authenticating against a Mac OS X server.
Of course lpq, lprm and lpr work as well.
Posted by Joe Mullins at September 16, 2004 04:44 PM | TrackBack

