Trigger User launchAgents Before Login

Can I launch all the launchAgents associated with a user before they log in? If so, is there an event or mechanism I can use or simulate to achieve this? Is it possible to delay the login mechanism, till all the launchAgents are loaded. Looking for guidance on how to approach this.

Why would you want to do this? And why would you think this would be a good idea?

I don't want programs running before I login. What's the point in doing that?

One of my launch daemons needs to fetch certain user-level information, which is only possible after the launch agent is loaded at the user level. Is there any work around to achieve this?

A launchd agent is configured to run in certain session types. Sessions come and go as users log in and out. Remember there can be multiple user sessions, with an arbitrary mix of GUI and non-GUI sessions. There’s also a pre-login session, and you can create a pre-login agent to run there. This is covered in a lot more detail in TN2083 Daemons and Agents. And the PreLoginAgents sample code shows how to configure your agent to run in the pre-login session.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thanks for the response. But is there any method to start a user gui session in the background to load the launchAgent. I want the launchAgent to be loaded at a certain specific user level.

But is there any method to start a user gui session in the background to load the launchAgent.

There’s no supported way to do this.

This is a pretty unusual request. What’s your high-level goal here?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Trigger User launchAgents Before Login
 
 
Q