Wrapper Macro for `defaults import`

A small utility macro that allows you to conveniently import application preferences.

Since nowadays the preferences of applications are handled by the cfprefsd, it is not possible (in most cases) to import preferences by just copying an app’s plist preferences file. The preferred way to do this is with defaults import <domain> <plist file to import from>.

Basically this macro is just a wrapper for the defaults import command.

Defaults Import [v0.5].kmmacros (28.9 KB)

Macro overview

Use-cases

  • Your internal disk has died, and you want to restore previous application preferences from the backup of your old ~/Library/Preferences.
  • You want to import app preferences from another Mac.

Usage

  1. Select one or more preference plist files, from where you want to import the preferences, in the Finder.
  2. Make sure that any app that uses these preferences is not running.
  3. Run the macro (by default from the Status Menu).

Feedback

You will get a notification like this:

If you have enabled the Verbose option in the macro, you will get an additional window like this:

The Verbose option is mainly useful if you import from multiple plist files in one go, since the notification can display only one import result.

Options

The green actions at the beginning of the macro are user options. Set them to 1 or 0.

  • The already mentioned Verbose option (report window with all imported domains and source paths).
  • The macro does a (cheap) content check, to see if a source plist file is a valid (i.e. typical) preferences file. If it thinks it is not, or if it cannot read the file, you should get a prompt before proceeding. But:
    • Depending on the location of your source preferences file, the macro may not be able to read the file, but the import may still be possible.
    • It is also possible that it returns a false positive.
    • If this happens frequently, you can disable the check altogether by setting the local Check File Content variable to 0.

Disclaimers

  • I’ve written the macro to import old preferences after my internal disk has died recently. I have mainly used it to import plist files one by one; the functionality to work on multiple selections was added towards the end and it not as thoroughly tested.
  • Keep in mind that the macro is a “zero” version; I stopped developing it after I had imported most of my old preferences with it.
  • It might not always be a good idea to import an app’s preferences from a different Mac model, or if the app versions aren’t the same.

Alternative Methods

  • If you have not yet installed an application on the target system, it might work to simply copy its plist file in the Finder. Though, I would rather use defaults import (or the macro) also in that case.
  • You can use Thomas Tempelmann’s excellent PrefsEditor to copy the contents (or parts of it) of a plist file of an already installed app and sync it to the cfprefsd cache.
    • To do this, you have to copy the source plist file into your active Preferences directory (without overwriting the target plist file) first. After copying the contents, you can delete it again. (This clunky procedure is necessary because of a (presumable safety) restriction built into PrefsEditor that prevents it from reading a plist file that is not located in your active Preferences folder.)

Tip

If an application’s preferences are not very numerous or complex, don’t import your old preferences, but let the application create the plist file from scratch. This will never hurt, and is certainly better than importing an old plist file that has been passed from system to system for the last twenty years.


Edit:

  • Aug 27, 2024
    • Better description of the options (in the post).
3 Likes

Nice!

Yeah, I shudder to think of the cobwebs, crumbs, and carcases of dead insects left around from long ago. :scream:

2 Likes