 |
 |
Editing .plist
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Dec 2003
Status:
Offline
|
|
Hi, I'd like to control the printing system in 10.3 without having to select options in the print dialog boxes. I already have all of my print settings stored as a custom profile named 'CoverPrint2'. This profile is stored in
Library/preferences/com.apple.print.custompresets.plist
and here is what the file contains (well, the important part anyway):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CoverPrint</key>
<dict>
<key>com.apple.print.preset.id</key>
<string>CoverPrint2</string>
<key>com.apple.print.preset.settings</key>
<dict>
<key>com.apple.print.PrintSettings.PMCopies</key>
<integer>88</integer>
Okay - still with me? What I really want to do is to be able to enter a command of the form
defaults write xxxx
to enable me to change the PMCopies property. Then, I can have control ver the default number of copies printed. Anyone know the command I should use? Thanks in advance
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Apr 2001
Location: Long Beach, CA
Status:
Offline
|
|
my guess would be:
defaults write com.apple.print.custompresets com.apple.print.PrintSettings.PMCopies 42
|

ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Dec 2003
Status:
Offline
|
|
Cheers for the response. However, when I try this, it just creates a new key at the bottom of the document. I think that becuase the value I want to change is so 'nested', I will need a longer 'address' to pass to defaults.
Any more ideas greatly appreciated
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Jul 2001
Location: NC
Status:
Offline
|
|
As far as anyone I know has been able to determine, defaults can only edit at a limited depth. One can use defaults to read data into a script, edit it and write it back but at that point, it's easier to just edit the propertylist directly. You said that the propertylist was in Library/preferences but you didn't say which one. I'll assume it's in your home directory. The following script takes a number as an argument and replaces the PMCopies value with that number:
#!/bin/bash
cd ~/Library/preferences
mv com.apple.print.custompresets.plist com.apple.print.custompresets1.plist
awk '! /PrintSettings\.PMCopies/; /PrintSettings\.PMCopies/{ print; getline; sub( /<integer>[0-9]*<\/integer>/, "<integer>'$1'</integer>" ); print }' com.apple.print.custompresets1.plist > com.apple.print.custompresets.plist
rm com.apple.print.custompresets1.plist
If my assumption about where the propertylist is, just change the "cd" line. I hope this does what you want.
|
|
Gary
A computer scientist is someone who, when told to "Go to Hell", sees the
"go to", rather than the destination, as harmful.
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |