22

I have notifications in the OSX Notification Center, as for most of my apps I am using the setting, "Show in Notification Centre: 10 Recent Items" This is a good setting but rather than have a very full Notification Center, I would still like to clear it from time to time with 1 click.

I am using Yosemite 10.10.3

8
tell application "System Events"
    tell process "NotificationCenter"
        set numwins to (count windows)
        repeat with i from numwins to 1 by -1
            click button "Close" of window i
        end repeat
    end tell
end tell

Copy and Paste the above code into AppleScript Editor Enable Script Editor in Accessibility

System Preferences enter image description here

  • Fantastic solution! I mapped your script to a keyboard shortcut in BTT: boastr.net – cody.codes Sep 28 at 15:30
7

Another option, which uses Keyboard Maestro to run an Applescript is detailed here: http://genuinecuriosity.com/unnotify

I have it mapped so that I hit Command Option 0 to clear all open alert dialogs.

Basically, I have created an Applescript to click the first button on all open alerts (typically Close), and does that until all alerts are cleared. You can use the Applescript directly through Keyboard Maestro (as described in my article), or you can create a Service with Automator (this is a little more finicky due to Accessibility permissions requirements).

The full Applescript is included in the article, along with a screen grab showing the setup in Keyboard Maestro. Script employed in Keyboard Maestro

  • It's helpful if you briefly summarize the linked reference as links can go stale in the future. – Allan Jun 6 '16 at 9:28
  • Brilliant thank you! You can copy paste the script into Alfred as well. – Dylanthepiguy Oct 20 '17 at 5:40
5

I don't know a way to clear every notification with a single button, however you can clear all of one app's notifications by moving your mouse to the right of the app's header and clicking the small x button that appears there.

To clear them all, I simply move the mouse to the topmost app's x button and rapidly click which removes all of the notifications relatively quickly.

  • 1
    thanks, that is what I do. Clicking the small x at the top of each notification section for 20 apps, is definitely not fast in my book. Not sure why you popped reply as an answer. – sea May 4 '15 at 18:18
  • @sea Haven't got comments yet – Séb May 4 '15 at 18:50
  • 1
    I don't see any "small x" on El Capitan 10.11.1 – Meekohi Nov 3 '15 at 14:35
  • 2
    You can close by day, if you hover over the day header line. – Tetsujin Apr 7 '16 at 14:36
4

I ended up creating an Automator script to do this and mapping it to a global hotkey.

on run {input, parameters}
    tell application "System Events"
        tell process "Notification Center"
            set theWindows to every window
            repeat with i from 0 to number of items in theWindows
                try
                    set this_item to item ((number of items in theWindows) - i) of theWindows
                    click button 1 of this_item
                on error
                    -- nothing
                end try
            end repeat
        end tell
    end tell
end run
3

I know this was originally for Yosemite, and I'm not sure the answer there, but given the question is 3 years old, and I just found it while looking for the same thing with Mojave, I thought I'd mention the answer I found.

enter image description here

on the very right of the menu bar, click on the 3 lines, this brings up a window with Today / Notifications tabs. If you select the Notifications tab, you can click the X to the right of Today to clear all the notifications for a given day. a few clicks and you'll have all the old ones cleared.

  • Would this clear a backlog of notifications? – ChristoKiwi Dec 16 '18 at 22:26
  • yes, that's the idea. I use it periodically to clear out a lot of notifications. – Kem Mason Dec 18 '18 at 20:24
  • If u wanna stay away from scripts this is the answer! – Ben Racicot Mar 27 at 13:41
2

This SIMBL app does the trick nicely. chuckhendo/NotificationClear: SIMBL bundle to add a "Clear All" button to Notification (https://github.com/chuckhendo/NotificationClear)

Just install it using mySIMBL. w0lfschild/mySIMBL: SIMBL plugin manager for macOS (https://github.com/w0lfschild/mySIMBL)

Once installed, you can just open the notification center, then click "Clear" on the bottom.

1

The small X in El Capitan is in the notification window. Open the Notification pane by sliding in from the right on the mouse or clicking on the notification center icon in the upper left corner. Each application's notifications are grouped together and there is a little X on the right side of each application's header. Click that X and the notifications all go away.

-3

Just go into the activity monitor and force quit the notification center...

  • Welcome to Ask Different and thank you for your answer. :) Unfortunately, short answers such as this don't really provide enough detail or context to help many users. If possible, it'd be good if you could add some more info keeping in mind many users won't know how to go about doing this. Also, you may want to read How to Answer for tips on providing answers here. – Monomeeth Nov 17 '18 at 3:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .