Skip to content

Instantly share code, notes, and snippets.

@cicero343
Created July 19, 2024 15:29
Show Gist options
  • Save cicero343/72deec0f9e808115aeb185042ae6bbdd to your computer and use it in GitHub Desktop.
Save cicero343/72deec0f9e808115aeb185042ae6bbdd to your computer and use it in GitHub Desktop.
Mac Notification PopUp
#!/bin/bash
# This script contains an if function which will open the Software Update section on the user's Mac when they select OK, please feel free to remove or change this as you wish.
# Function to display the warning message using AppleScript
display_warning() {
local window_title="<WINDOW TITLE HERE>"
osascript -e 'display dialog "<YOUR TEXT HERE>" with icon POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AppleTraceFile.icns" buttons {"OK", "Cancel"} default button "OK" with title "'"$window_title"'"' -e 'button returned of result' 2>/dev/null
}
# Call the function to display the warning message and store the button clicked by the user
button_clicked=$(display_warning)
# Check which button was clicked
if [ "$button_clicked" == "OK" ]; then
open "x-apple.systempreferences:com.apple.preferences.softwareupdate"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment