Skip to content

Instantly share code, notes, and snippets.

@Sangdol
Created July 23, 2022 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sangdol/4d3122f61f1d923718342c55146224b6 to your computer and use it in GitHub Desktop.
Save Sangdol/4d3122f61f1d923718342c55146224b6 to your computer and use it in GitHub Desktop.
An AppleScript that marks notifications as completed
# 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 "Complete" then
tell theWindow
perform theAction
# delay to prevent it from stopping in the middle
# it's not certain why it stops when there's no delay
delay 0.5
my closeNotif()
end tell
else 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