My question is fairly straight forward: can you have more than one LoginHook or more than one LogoutHook?

I've done my own research and it looks like every time you add a new LoginHook, the previous one goes away. I think I can confirm this by running the old:

sudo defaults write com.apple.loginwindow LoginHook /path/to/script

Then checking to see that the loginhook is registered in the /var/root/Library/Preferences/com.apple.loginwindow.plist, then repeat the process by adding another loginhook, looking at the root loginwindow plist to see that the second script was over written by the first. There is never more than one.

Is that correct? Are you ever only able to have one LoginHook?

  • In programming terms, LoginHook is the key to an array element, /path/to/script its value. You don't add new values, but set, overwriting the existing one. – Daniel Beck Jan 11 '12 at 21:18

This is not possible. Quoting here:

There is only one login hook, which means that it's not suitable for shrink wrap developers because you can't be guaranteed that the user hasn't already installed some other software that's using it. In general, you should consider the login hook to be reserved for use by site administrators.

The linked article mentions multiple alternatives. A Launch Agent might work for login, depending on your specific requirements.

There is no alternative to logout hooks. Quoting the same article:

Specifically, while the authorization plug-in technique described in this technote is a good alternative for the login hook, there is currently no equivalent replacement for the logout hook.

See also this unanswered question.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.