Drag & Drop / Copy & Paste

For this example, I’m going to be using the key AppleAquaColorVariant from NSGlobalDomain. In case anybody is wondering, this key is what lets the system know what Appearance setting to use — the default “Blue” or “Graphite.” I’d suggest not actually using Pref Setter to set this, but rather the Appearance preference pane. It works if you set it via Pref Setter, but running applications don’t get notified of the change like setting it with the Appearance preference pane does. As I said, just an example I’m using.

Sections:
Dragging or pasting “defaults write…” strings
Dragging or pasting XML strings
Dragging Property List files
Dragging or Pasting to Other Applications

 

 

Dragging or Pasting “defaults write…” strings

You can drag or paste a defaults write… string onto either the “Open Domain Quickly” window or the document windows. You can also drag (but not paste) a defaults write… string onto tabs. When you do, Pref Setter will open up the domain the defaults string points to (if it’s not already open) and apply the setting. Very easy, and likely the only interaction you’ll have from doing this is a dialog asking you if you want to replace the old value.

Pref Setter expects the string to be formatted along these lines: defaults write NSGlobalDomain AppleAquaColorVariant -int 1. If there are spaces in the domain name, the key, or the value, you need to either place quotes around them or use shell quoting (a ‘\’ character before the spaces). As an example of this (and this is a purely made up combination): defaults write “com.some domain with spaces.someApp” A\ Key\ With\ Spaces -string “A value with spaces”

If the value is a string, you don’t need the -string identifier before the value, but if it is something else, you'll need to specify it (the identifiers that defaults recognizes are -string, -data, -int[eger], -float, -bool[ean], -date, -array, -array-add, -dict, -dict-add).

If Pref Setter doesn’t have sufficient privileges to write to the domain, it’ll display an alert letting you know.

Dragging or Pasting XML strings

Pref Setter will accept a drag or paste on the document windows of an XML string in property list format. You can also drag (but not paste) XML strings onto tabs. When you drag or paste, the string will be placed in that particular document — it doesn't open up a particular domain to apply these to.

These strings can be in full property list format, or a partial one. Here are some examples, and how Pref Setter will use them:

Here's an XML string in full property list format:

<?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>AppleAquaColorVariant</key> <integer>6</integer> </dict> </plist>

With the above, Pref Setter will create a new entry with a key named AppleAquaColorVariant with an integer value of 6.

Here’s a few partial XML strings. Pref Setter will read each of the next examples exactly the same as the above:

<plist version="1.0"> <dict> <key>AppleAquaColorVariant</key> <integer>6</integer> </dict> </plist>
<plist> <dict> <key>AppleAquaColorVariant</key> <integer>6</integer> </dict> </plist>
<dict> <key>AppleAquaColorVariant</key> <integer>6</integer> </dict>

Pref Setter will take this next example, but it will read it differently than the above:

<key>AppleAquaColorVariant</key> <integer>6</integer>

If you dragged or pasted the above into Pref Setter, it would create a new entry with a name of 6 and a value of 6. This is because key names are only accepted when they are inside a dict statement. You can also drag just a value into Pref Setter, and it will do the same as the above: give it a name that is the same as the value, like this:

<integer>6</integer>

You aren’t limited to only dragging one key/value pair. I’ve only been using one to simplify the example, but you can drag multiple key/value pairs, like this:

<dict> <key>AppleAntiAliasingThreshold</key> <integer>6</integer> <key>AppleAquaColorVariant</key> <integer>6</integer> </dict>

Dragging Property List files

In addition to dragging XML strings, you can drag an entire plist file onto a document or tab, and that file’s entire contents will be added to that particular document.

Dragging or Pasting onto other applications

Pref Setter will allow a drag or paste from a document to another application, so long as the other application accepts strings.

When you drag or paste onto another application, you'll get output similar to the below:

defaults: defaults write NSGlobalDomain AppleAquaColorVariant -int 1 XML: <?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>AppleAquaColorVariant</key> <integer>6</integer> </dict> </plist>

You can also drag multiple items at once — you’re not limited to only one! When you drag multiple items, their defaults and XML strings get coalesced together like this:

defaults: defaults write NSGlobalDomain AppleAntiAliasingThreshold -int 6 defaults write NSGlobalDomain AppleAquaColorVariant -int 6 XML: <?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>AppleAntiAliasingThreshold</key> <integer>6</integer> <key>AppleAquaColorVariant</key> <integer>6</integer> </dict> </plist>
The DEFAULTS command can not handle nested dictionaries or arrays. So, if you drag / paste an array or dictionary that itself contains arrays or dictionaries, you'll get the string “Sorry, defaults can’t handle the nested dictionaries / arrays in the key: “KEY_NAME””