Mac OS X Services: enable without user interaction?
I wrote a simple Mac 'Service' for Finder, that executes a command. Basically: this adds a ContextMenu in Finder. If I right-click a file in F开发者_开发问答inder, a menu item pops up. If the user clicks it, it executes my script. (kind of like 'Send to Bluetooth device, ...')
In OS X Leopard (10.5) and earlier, all services are enabled. In 10.6 (Snow Leopard), Apple changed the behavior, services now have preferences, and can be enabled or disabled by the user. (which is a good thing)
However, I wrote the service, but there seems to be no way to enable it automatically (in our installer). I tried doing it with Applescript, going to the System Preferences and ticking the checkbox that way, but it requires some accessibility features to be turned on. (off by default).
Is it possible? If so, how? Or do I need something else to provide Context Menus in Finder.
I tracked File changes on my filesystem while changing the preferences and discovered there was a plist file:
~/Library/Prefrences/pbs.plist
which contains what I need. If I edit that manually, it seems to work. So, problem solved :)
精彩评论