Login & Logout Hooks
If you want to have a script run when a user logs in and/or logs out then you’ll likely want to look into using login and logout hooks. A hook is a script that runs as root (although you can execute as the user with su). Hooks are enabled in the /var/root/Library/Preferences/com.apple.loginwindow. You can do so using defaults, writing the path to the script into LoginHook as a string as follows:
defaults write com.apple.loginwindow LoginHook /scripts/script.sh
defaults write com.apple.loginwindow LogoutHook /scripts/scripts.sh
Similar Articles:
- Disable Automatic Login Programatically
- LoginWindow Customizations in Mac OS X
- Mac OS X: Hey, where's my admin user?
- Scripting the Force Log Out
- New Tool For Hiding Users
Leave a comment