Jump to content

Clearing Multiple Notifications


Recommended Posts

Hi,

I was looking for a workflow that can clear existing notifications from Notification Center panel. I found few but none of them seems to work with Alfred 4 / MacOS 12.3.1. If anyone can help that would be awesome.

 

Links that i found

https://github.com/skotzko/shhhhh

https://github.com/skotzko/shhhhh/issues/7#issuecomment-874773375

https://www.ryanmo.co/2016/04/18/clearing-multiple-notifications-in-mac-os-x/

 

Thanks

 

 

Link to comment

Those stopped working because they rely on GUI automation and Apple has since changed the Notification Centre. At the time I looked into it (and likely still the case) there wasn’t a good alternative to doing so.

 

Your best bet is to learn to live with those notifications, instead of trying to clear them. Note they won’t go on forever, they only go back seven days and anything older disappears, so there’s no need for manually clean them up.

Link to comment
  • 3 months later...
10 minutes ago, alfredpanda said:

I'd love to be able to clear with an Alfred shortcut.

 

The code is JXA, so you can do it in an Alfred Run Script with language set to /usr/bin/osascript (JavaScript). My previous reply still applies: those solutions use GUI automation, which is why they break when Apple makes changes.

Link to comment
  • 2 weeks later...
On 8/16/2022 at 5:03 PM, vitor said:

 

The code is JXA, so you can do it in an Alfred Run Script with language set to /usr/bin/osascript (JavaScript). My previous reply still applies: those solutions use GUI automation, which is why they break when Apple makes changes.

 

Tried https://github.com/zakyum/alfred-notification-dismisser and some scripts but there are not very reliable. Perhaps will live with notification as it is instead of clearing all. 

Link to comment
  • 4 weeks later...

How are you making this work? It's not working for me on 12.5.1.

 

I have notifications in Notification Center.

I run it in Alfred.

...nothing.

 

I wondered if Notification Center had to remain open, but it's impossible to do that.

 

image.thumb.png.e28441c16659f4056fa401680073504f.png

 

EDIT:

 

Got it—I was misunderstanding. This will indeed clear any persistent notifications on screen - thank you. It won't however clear what's in notification center.

Edited by alfredpanda
Link to comment
  • 4 months later...
  • 2 months later...

I slightly modified the above script to work on macOS Ventura 13.3, Unfortunately this won't clear all notification just one at a time.

 

tell application "System Events"
    try
        click menu bar item 1 of menu bar 1 of application process "Control Center"
    end try
    try
        set _groups to groups of UI element 1 of scroll area 1 of group 1 of window "Notification Center" of application process "NotificationCenter"
        repeat with _group in _groups
            set _actions to actions of _group
            
            repeat with _action in _actions
                if description of _action is in {"Schlie§en", "Alle entfernen", "Close", "Clear All"} then
                    perform _action
                end if
            end repeat
        end repeat
    end try
    key code 53 # Escape Key
end tell

 

Link to comment
  • 4 weeks later...

All you need to do is to copy the quoted script to a Run Script action in Alfred (see this help page about that action). When you double click on the action set it to /usr/bin/osascript (AppleScript). In this case you won't need the lines Alfred automatically adds (because you're not passing in any variable) so you can simply select all and overwrite with a copy of the quoted script from above.

 

Then all you need to do is to trigger the script—so before it add a hotkey or keyword trigger.

 

Stephen

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...