-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwait_for_user
More file actions
31 lines (29 loc) · 1.23 KB
/
wait_for_user
File metadata and controls
31 lines (29 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#Checks if a user is logged in yet, and if not it waits and loops until we can confirm there is a real user
function wait_for_user()
{
#Set our test to false
verifiedUser="false"
#Set our timer for how long between loops
sleepTimer=5
#Loop until user is found
while [ "$verifiedUser" = "false" ]; do
#Get currently logged in user
currentUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ { print $3 }' )
#Verify the current user is not root, loginwindow, or _mbsetupuser
if [ "$currentUser" = "root" ] \
|| [ "$currentUser" = "loginwindow" ] \
|| [ "$currentUser" = "_mbsetupuser" ] \
|| [ -z "$currentUser" ]
then
#If we aren't verified yet, wait $sleepTimer seconds and try again
sleep $sleepTimer
else
#Logged in user found, but continue the loop until Dock and Finder processes are running
if pgrep -q "dock" && pgrep -q "Finder"; then
#You may wish to add a log message or annoucement here that serves your purposes
#echo "An end user session has been identified: $currentUser"
verifiedUser="true"
fi
fi
done
}