diff --git a/assessment-toggle.applescript b/assessment-toggle.applescript index 3c6376f..993a2ef 100644 --- a/assessment-toggle.applescript +++ b/assessment-toggle.applescript @@ -1,13 +1,40 @@ -try - do shell script "spctl --status" - do shell script "spctl --master-disable" with administrator privileges - display dialog "Assessment disabled!" buttons {"OK"} default button 1 -on error +script toggle try do shell script "spctl --status" - display dialog "Error!" buttons {"OK"} default button 1 + do shell script "spctl --master-disable" with administrator privileges + display dialog "Software assessments are disabled now!" buttons {"OK"} default button 1 with title "Information" on error - do shell script "spctl --master-enable" with administrator privileges - display dialog "Assessment enabled!" buttons {"OK"} default button 1 + try + do shell script "spctl --status" + display dialog "Error!" buttons {"OK"} default button 1 with title "Information" + on error + do shell script "spctl --master-enable" with administrator privileges + display dialog "Software assessments are enabled now!" buttons {"OK"} default button 1 with title "Information" + end try end try -end try \ No newline at end of file +end script + +set looping to true + +repeat while looping = true + try + set spctl_status to do shell script "spctl --status" + on error + set spctl_status to "assessments disabled" + end try + + if spctl_status = "assessments enabled" then + set spctl_status to "enabled" + else + set spctl_status to "disabled" + end if + + set dialog_action to (display dialog "Software assessments are " & spctl_status & "!" buttons {"Exit", "Toggle"} default button 2 with title "Software Assessments Toggle") + set button_name to the button returned of dialog_action + + if button_name = "Toggle" then + run toggle + else + set looping to false + end if +end repeat \ No newline at end of file