Skip to content

Instantly share code, notes, and snippets.

@Sangdol
Created July 23, 2022 14:23
Show Gist options
  • Save Sangdol/7aed31e13f68b8f916045b5b3f1938b5 to your computer and use it in GitHub Desktop.
Save Sangdol/7aed31e13f68b8f916045b5b3f1938b5 to your computer and use it in GitHub Desktop.
An AppleScript that closes notifications
# https://apple.stackexchange.com/questions/408019/dismiss-macos-big-sur-notifications-with-keyboard
my closeNotif()
on closeNotif()
tell application "System Events"
tell process "Notification Center"
set theWindow to group 1 of UI element 1 of scroll area 1 of window "Notification Center"
# click theWindow if you want to open the app
set theActions to actions of theWindow
repeat with theAction in theActions
if description of theAction is "close" then
tell theWindow
perform theAction
delay 0.5
my closeNotif()
end tell
end if
end repeat
end tell
end tell
end closeNotif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment