Rename displayAppleScriptFunction.sh to dialogAppleScriptFunction.sh

This commit is contained in:
Adam Codega
2022-03-01 11:53:55 -05:00
committed by GitHub
parent 68c5feed37
commit 3f602fc6e1

View File

@@ -0,0 +1,15 @@
# this function is Bash compatible, insert the function in your script and then place displayAppleScript where you want it to be executed
displayAppleScript(){
message="A problem was encountered setting up this Mac. Please contact IT."
currentUser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ { print $3 }')
if [[ "$currentUser" != "" ]]; then
currentUserID=$(id -u "$currentUser")
launchctl asuser "$currentUserID" /usr/bin/osascript <<-EndOfScript
button returned of ¬
(display dialog "$message" ¬
buttons {"OK"} ¬
default button "OK")
EndOfScript # this line *must* use tabs and not spaces. Ensure your text editor does not change them.
fi
}