From 68c5feed37e7ddea57ff7959fca7752f844d3fe6 Mon Sep 17 00:00:00 2001 From: Adam Codega Date: Tue, 1 Mar 2022 11:49:56 -0500 Subject: [PATCH] Create displayAppleScriptFunction.sh --- displayAppleScriptFunction.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 displayAppleScriptFunction.sh diff --git a/displayAppleScriptFunction.sh b/displayAppleScriptFunction.sh new file mode 100644 index 0000000..c01e73f --- /dev/null +++ b/displayAppleScriptFunction.sh @@ -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 +}