I have long used an Applescript triggered from a keyboard shortcut to dismiss notifications on MacOS. It worked by simulating a click of the "close" button of every open Notification Center window.
Since upgrading to Big Sur (currently 11.0.1), notifications no longer have a close button. Instead, when you hover over them with the mouse, an "X" button will appear. For a person who has difficulty clicking precisely (I have a slight hand tremor), using the mouse/trackpad is difficult.
Anyone have suggestions on how to restore that functionality so I can just keep my hands on the keyboard?
My Settings
I am using Automator to test this.
In System Preferences > Notifications, I selected Automator:
- Allow Notifications is true.
- Automator alert style: is Alerts.
- Notification grouping is automatic.
Testing
- I opened Automator and created a new workflow.
- I added three instances of the Display Notification action.
- I gave them Title: values of
test 1
,test 2
, andtest 3
. - And Subtitle: values of
subtitle 1
,subtitle 2
, andsubtitle 3
. - And Message: values of
message 1
,message 2
, andmessage 3
. - I ran the workflow using ⌘+R.
- In the upper-right corner of my screen, I see a notification from Automator stacked over two others. Only notification
test 3
is fully visible and it has the notation "2 more notifications" at the bottom.
@AndrewJanian 's Script
- Again, thank you, Andrew for providing the script!
- I added the line
#!/usr/bin/osascript
to the start of the script and saved it asandrew.applescript
. - I made the file executable. (
chmod 755 andrew.applescript
). - I ran it in a terminal window (
./andrew.applescript
) - The result of running is:
- the grouped notifications become ungrouped (so I see
test 3
,test 2
, andtest 1
stacked top to bottom in the notification area - the terminal displays the following error
./andrew.applescript:370:377: execution error: System Events got an error: Can’t get action "Name:Clear All Target:0x60000116ff20 Selector:_internal_handleCustomActionWithUiAction:" of group 1 of UI element 1 of scroll area 1 of window "Notification Center" of application process "NotificationCenter". (-1728)
- the grouped notifications become ungrouped (so I see
I'll try messing around with it to see if I can make it work with modifications.
Note: If I run the script again, starting from the ungrouped state:
- it dismisses the top-most notification (
test 3
) - and it displays the following in the terminal:
action Name:Close Target:0x60000116ff20 Selector:_internal_handleCustomActionWithUiAction: of group 1 of UI element 1 of scroll area 1 of window Notification Center of application process NotificationCenter
X
to click on—it's almost like they wanted to make it as small as the "close" button for mobile ads. :-)X
if you happen to have trackpad. While hovering anywhere over notification two finger swipe from left to right should dismiss it. From productivity perspective I personally don't believe that on desktop notifications and immediate interaction with them is good workflow.