Of NSServices and lsregister

March 5th, 2008
Spencer Nielsen Follow snielsen42 on Twitter

Services

Launch Services is one of those things that does a lot of magic for Mac OS X but is not really visible on the surface and is somewhat vague and ethereal. Launch Services is responsible among other things, for associating file types with applications, associating icons, associating system services and many other wonderful things that make your experience just work. Fortunately there is a tool to poke at the Launch Services database buried in the system at:

/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister

Most notably the -dump command basically outputs the database so that you can see exactly why a certain file type wants to be opened by which app and why certain files get their icons and association hijacked by some other random new app. The -f command will let you update the database with any new changes you have made to an application or bundle.

Some of things managed by this database are the system services that show up in the “Services” option under the application menu (these are outlined in the NSServices array of a bundle’s Info.plist). Language Aid provides one of these as an alternative to the lookup trigger and contextual menu as a way to lookup text. Unfortunately, it appears that just tickling the database with the new information about which options you want available in the menu (dictated by which plugins you have selected), is not enough to rebuild the Services menu. A reboot seems to do the trick, but it would really be nice if I could figure out what causes that menu to rebuild.

Leave a Reply

Entries (RSS) and Comments (RSS).