I have created Cocoa app which is type of launch agent. To distribute this I have created package as well which installs the app and copies the launchagnet plist file in /Libraries/LaunchAgents.
Now the problem is after installation i want this app to be running in user context immediately without logoff/restart. If I register this with “launchctl” from installer, using post install script, it run in root context, as installer is running in root context.
Any suggestion how the agent registers itself to launchctl and runs in user context.
Try this in the postinstall script:
Note that if multiple users are logged in via Fast User Switching, this will only activate your launch agent for the user who installed it.
There is an unsupported way to make this work with multiple users logged in on Mac OS X 10.5/10.6, using
launchctl bsexec; see this mailing list post for more information.