oz_penguin ([info]oz_penguin) wrote,
@ 2009-07-02 15:15:00
Previous Entry  Add to memories!  Tell a Friend  Next Entry
Current mood: working
Current music:The slightly louder hum of computer fans...
Entry tags:"macos x", printing

Defining global printer presets for all users on a MacOS X computer
Note: All references to "MacOS X" in the following apply to Leopard (MacOS 10.5) and Tiger (MacOS 10.4). I haven't needed to investigate how the earlier versions did things.

As part of the implementation of our new unified printing and copying system, I needed to find a way to enforce some printing defaults on the various printer queues. On the Windows side this was relatively easy; settings assigned to the queues on the print server are inherited by all users on the domain.

MacOS X does things a bit differently. One of the things I like about Mac printing is that users can create printer "presets" that are printer-independent. You start with the default "Standard" preset, make the changes you want (eg duplex printing, forced B&W output etc), and then save the new profile under a name of your choice. You can use these profiles with any of your printers, and the Mac quietly ignores any of the settings that don't apply to that particular printer (eg duplex printing on a printer that can't duplex).

Each user on the Mac can have their own set of unique presets. Leopard and Tiger store the printer presets in the file

~/Library/Preferences/com.apple.print.custompresets.plist

But what if you want to provide a common set of presets to all users on the Mac?


It turns out to be relatively simple.

Log on to the machine as a user with admin privileges. Rename

~/Library/Preferences/com.apple.print.custompresets.plist

to

~/Library/Preferences/com.apple.print.custompresets-old.plist

Why? Because it may already contain custom presets that you don't want to provide to all users.

Now, fire up an application that is able to print something (a web browser is a good example). Create the various custom presets you need. In our case, we had 4 custom presets:


  • BandW duplex

  • BandW single-sided

  • Colour duplex

  • Colour single-sided



Once you've created all of the presets you need, select the one you want to be the default, and then print something. A single page is fine. This ensures that the value of the field "com.apple.print.lastPresetPref" in your .plist file is set to the correct value (if you have the developer tools installed, you can user Property List Editor to set this value instead of having to print).

Once you've done that, close all of your open applications. You need to change the permissions on

~/Library/Preferences/com.apple.print.custompresets.plist

to make it universally readable, and then move the file into

/Library/Preferences

This makes the presets available to all users on the Mac.

It's possible, however, that a user already have their own set of custom presets. It's even possible that they have a preset with the same name as one of your new global presets. If so, their preset will mask the global preset. Running the following Perl script using sudo will rename all users custom presets files. Renaming is safer than deleting, as you're just as likely to find one user who spent months perfecting their printer profiles to get the best output when printing photos etc, and you'll want to be able to re-instate them if needed.


#!/usr/bin/perl

$subPath="/Library/Preferences/";
$oldName="com.apple.print.custompresets.plist";
$newName="com.apple.print.custompresets-old.plist";

@paths=;

foreach $path (@paths) {

$path2check= "$path$subPath$oldName";

$newPath= "$path$subPath$newName";

if (-e $path2check) {
rename $path2check, $newPath;
}
}


To push this out site-wide, I used package maker to create an installer package that installed the new global presets and ran the Perl script post-install. I then pushed it out to all of our Macs using Apple Remote Desktop.




(2 comments) - (Post a new comment)

making a print installer for duplex printing.
(Anonymous)
2009-07-27 04:12 pm UTC (link)
Is there a way to merge the 2 custom presets files if there is one already present in the user's preference files? I've tried what you said and in testing, the custom presets in the user's prefs don't allow the file in /Library/Preferences/ to show up. I want to make an installer that does not mess with the user's custom presets at all. Is there a way to do that?
-Jeff

(Reply to this) (Thread)

Re: making a print installer for duplex printing.
[info]oz_penguin
2009-09-01 06:39 am UTC (link)
A good question. The following is based upon my experiences when I was figuring this out, and applies to both Tiger and Leopard.

Lets assume that the plist file in /Library/Preferences defines the four presets I described above, and that it specifies that "BandW duplex" should be the default.

Then let us assume that user bloggsj has a plist file in place, that defines two presets named fred and john, with fred being the default.

If the permissions on the /Library/Preferences plist file are set to be universally readable, bloggsj should see all six presets, and fred will be their default. The plist files at the various levels are additive, and the user's preferred preset will take precedence over the one set in /Library/Preferences.

If bloggsj already ha a preset named "BandW duplex", then it would override the setting specified in /Library/Preferences. This is one of the reasons why I shunted the users plist files aside, so that they wouldn't have same-name presets that override our system-level presets.

But please note the "If the permissions on the /Library/Preferences plist file are set to be universally readable" above. When I first put a plist file in /Library/Preferences, I hadn't set the permissions to make it universally readable. As a result, the users didn't have access to it, and the system-level presets weren't available to them.

(Reply to this) (Parent)


(2 comments) - (Post a new comment)

Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…