Skip to content

Commit f4dc1ac

Browse files
committed
adding prompt timeout
1 parent 3422299 commit f4dc1ac

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

screennudge_prompt.zsh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
###########################################################################################
1717
# Created by Brian Van Peski - macOS Adventures
1818
###########################################################################################
19-
# Current version: 1.6.1 | See CHANGELOG for full version history.
20-
# Updated: 01/03/2023
19+
# Current version: 1.6. | See CHANGELOG for full version history.
20+
# Updated: 10/12/2022
2121

2222
# Set logging - Send logs to stdout as well as Unified Log
2323
# Use 'log show --process "logger"' in Terminal to view logs activity and grep for ScreenNudge to filter.
@@ -35,6 +35,9 @@ appIcon="/Applications/zoom.us.app/Contents/Resources/ZPLogo.icns" #Path to app
3535
dialogTitle="Screen Recording Approval"
3636
dialogMessage="Please approve screen recording for $appName."
3737

38+
attempts=6 #How many attempts at prompting the user before giving up.
39+
wait_time=40 #How many seconds to wait between user prompts.
40+
3841
##############################################################
3942
# VARIABLES & FUNCTIONS
4043
##############################################################
@@ -74,7 +77,7 @@ UserDialog (){
7477
# THE NEEDFUL
7578
################################################################
7679
#Check for a valid bundleid
77-
if ! [[ $bundleid =~ ^[a-zA-Z0-9]+[-.](.*) ]]; then
80+
if ! [[ $bundleid =~ ^[a-z0-9-]+(.[a-z0-9-]+)* ]]; then
7881
LOGGING "--- Could not find valid bundleid for $appName at $appPath!"
7982
exit 1
8083
fi
@@ -91,15 +94,21 @@ elif [[ $scApproval == "$bundleid" ]]; then
9194
elif [[ -d "$appPath" && $scApproval != "$bundleid" ]]; then
9295
LOGGING "--- $appName is installed with bundleid: "$bundleid""
9396
#Prompt user for Screen Recording Approval and loop until approved.
97+
dialogAttempts=0
9498
until [[ $scApproval = $bundleid ]]
9599
do
100+
if (( $dialogAttempts >= $attempts )); then
101+
LOGGING "Prompts have been ignored after $attempts attempts. Giving up..."
102+
exit 1
103+
fi
96104
LOGGING "--- Requesting user to manually approve ScreenCapture for $appName..."
97105
open "x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture"
98106
#Activating System Settings (Ventura Workaround)
99107
osascript -e 'tell application "System Settings"' -e 'activate' -e 'end tell'
100108
UserDialog
101-
#launchctl asuser 501 say -v Samantha 'Please approve Screen Recording for '$AppName' in System Preferences.' #optional voice annoyance prompt for depot/warehouse scenarios
109+
#launchctl asuser 501 say -v Samantha 'Please approve Screen Recording for '$AppName' in System Preferences.' #optional voice annoyance prompt for depot/warehous scenarios
102110
sleep 10
111+
((dialogAttempts++))
103112
LOGGING "--- Checking for approval of ScreenCapture for $appName..."
104113
Check_TCC
105114
done

0 commit comments

Comments
 (0)