This tutorial explains how to create a custom keyboard shortcut to close all macOS notifications using Automator and System Settings.
- Open Automator (use Spotlight Search or find it in Applications).
- In the window that appears, select Quick Action as the document type.
-
At the top of the Automator window:
- Set Workflow receives to
no input
. - Set in to
any application
.
- Set Workflow receives to
-
In the left sidebar, search for Run AppleScript.
-
Drag the Run AppleScript action into the workflow pane on the right.
Paste the following AppleScript into the Run AppleScript block in Automator:
tell application "System Events"
tell process "NotificationCenter"
if not (window "Notification Center" exists) then return
set alertGroups to groups of first UI element of first scroll area of first group of window "Notification Center"
repeat with aGroup in alertGroups
try
perform (first action of aGroup whose name contains "Close" or name contains "Clear")
on error errMsg
log errMsg
end try
end repeat
return ""
end tell
end tell
Test the script by clicking Run in Automator. If notifications are cleared, proceed to the next step.
- Go to File > Save in Automator.
- Name your Quick Action (e.g.,
CloseNotifications
) and click Save.
- Open System Settings (or System Preferences).
- Navigate to Keyboard > Keyboard Shortcuts.
- Select App Shortcuts from the list on the left.
- Click the + button to add a new shortcut:
- Application: Choose
All Applications
. - Menu Title: Enter the exact name of your Quick Action (e.g.,
CloseNotifications
). - Keyboard Shortcut: Assign a shortcut (e.g.,
Command + Option + N
).
- Application: Choose
- Click Add.
Press the assigned keyboard shortcut to run the Quick Action and clear all notifications. The script will execute, clearing all visible notifications from the macOS Notification Center.