From Apple’s Launch Services Programming Guide (all emphasis mine):
All applications available on the user’s system must be registered to make them known to Launch Services and copy their document binding and other information into its database. It isn’t ordinarily necessary to perform this task explicitly, since a variety of utilities and services built into the Mac OS X system software take care of it automatically:
- A built-in background tool, run whenever the system is booted or a new user logs in, automatically searches the Applications folders in the system, network, local, and user domains and registers any new applications it finds there. (This operation is analogous to “rebuilding the desktop” in earlier versions of Mac OS.)
- The Finder automatically registers all applications as it becomes aware of them, such as when they are dragged onto the user’s disk or when the user navigates to a folder containing them.
- When the user attempts to open a document for which no preferred application can be found in the Launch Services database, the Finder presents a dialog asking the user to select an application with which to open the document. It then registers that application before launching it.
In spite of these automatic registration utilities, it may sometimes be necessary to register an application explicitly with Launch Services. For example, although developers are encouraged to package their applications so that they can be installed by simply dragging them onto the user’s disk, some applications may require more elaborate custom installer software. In such cases, the installer should call one of the Launch Services registration functions LSRegisterFSRef
or LSRegisterURL
to register the application explicitly.
Note the API calls needed by the only named manual registration procedure (source not available on opensource.apple.com, I’m afraid).
While working around a bug in processing of Launch Services on Leopard with FileVault enabled, I noticed that ~/Library/Preferences/com.apple.LaunchServices.plist
is:
processed only on login after boot, as input data to the buildup of the Launch Services database proper (FileVault-enabled Leopard often failed to do this step, resulting in seemingly lost user settings); and
cached as long as the machine is not rebooted.
Simply put, it’s the user domain persistence layer of Launch Services, and modifications to that persistence layer are only acknowledged on next processing – reboot or reseed.
First off, you can check out a website that lists a lot of these things: http://secrets.blacktree.com/
I, however, just took a brute-force solution:
Copy the Preferences folder
$ cp -r /Library/Preferences before
Launch System Preferences.
Make a change via the GUI.
Probably best to do one change at a time,
e.g. I changed "Display Login Window as:"
from "List of users"
to "Name and password".
Quit System Preferences.
Copy the Preferences folder again:
$ cp -r /Library/Preferences after
See which files changed:
$ diff -ur before after
Binary files before/Preferences/com.apple.loginwindow.plist and after/Preferences/com.apple.loginwindow.plist differ
Compare the two versions.
Since they are binary files, you'll need to convert them to XML for comparison.
I use an alias for this:
$ alias plist='plutil -convert xml1 -o /dev/stdout'
$ diff -u <(plist before/Preferences/com.apple.loginwindow.plist) <(plist after/Preferences/com.apple.loginwindow.plist)
--- /dev/fd/63 2013-01-23 18:20:29.000000000 +0200
+++ /dev/fd/62 2013-01-23 18:20:29.000000000 +0200
@@ -9,7 +9,7 @@
<key>RetriesUntilHint</key>
<integer>3</integer>
<key>SHOWFULLNAME</key>
- <false/>
+ <true/>
<key>lastUser</key>
<string>loggedIn</string>
<key>lastUserName</key>
At this point we have located the setting. Confirm we have it with defaults
:
$ defaults read /Library/Preferences/com.apple.loginwindow SHOWFULLNAME
1
$ sudo defaults write /Library/Preferences/com.apple.loginwindow SHOWFULLNAME -bool false
$ defaults read /Library/Preferences/com.apple.loginwindow SHOWFULLNAME
0
Launch System Preferences and confirm it changed.
Best Answer
If you install gnu coreutils then gnu ls is available, which will do as required. If you use brew as a package manager, it's as simple as: