Skip to content

Instantly share code, notes, and snippets.

@gimmickyboot
Last active November 27, 2025 22:13
Show Gist options
  • Select an option

  • Save gimmickyboot/b5004af24a6d62959338905d0f485665 to your computer and use it in GitHub Desktop.

Select an option

Save gimmickyboot/b5004af24a6d62959338905d0f485665 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.domain.wait</string>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>/usr/local/bin/wait_for_valid_user_to_logon.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>root</string>
</dict>
</plist>
#!/bin/sh
while true; do
CurrentlyLoggedInUser=$(stat -f %Su /dev/console)
case "${CurrentlyLoggedInUser}" in
root|_mbsetupuser|_windowserver)
/bin/echo "At login window. Sleeping"
sleep 2
;;
*)
/bin/echo "${CurrentlyLoggedInUser} logged on. Continuing"
break
;;
esac
done
# rest of your script here. might need to wait until the Finder and Dock has launched (based on experience you should do this)
until /usr/bin/pgrep -qx Finder; do
/bin/echo "Waiting for the Finder to load for uomsetup"
sleep 1
done
until /usr/bin/pgrep -qx Dock; do
/bin/echo "Waiting for the Dock to load for uomsetup"
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment