jackk Posted April 20, 2022 Share Posted April 20, 2022 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
vitor Posted April 20, 2022 Share Posted April 20, 2022 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
jackk Posted April 20, 2022 Author Share Posted April 20, 2022 Dang that's unfortunate. Link to comment
Mattias Posted April 27, 2022 Share Posted April 27, 2022 This would be a great function. Link to comment
alfredpanda Posted August 16, 2022 Share Posted August 16, 2022 (edited) @vitor have you seen these? https://github.com/Ptujec/LaunchBar/tree/master/Notifications#readme https://gist.github.com/lancethomps/a5ac103f334b171f70ce2ff983220b4f I'd love to be able to clear with an Alfred shortcut. Edited August 16, 2022 by alfredpanda Link to comment
vitor Posted August 16, 2022 Share Posted August 16, 2022 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
TomBenz Posted August 28, 2022 Share Posted August 28, 2022 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
Stephen_C Posted August 28, 2022 Share Posted August 28, 2022 See also my reply to your other post here. Stephen Link to comment
bartoszpet Posted September 19, 2022 Share Posted September 19, 2022 This one works perfectly (tested with macOS Monterey 12.6): https://github.com/bpetrynski/alfred-notification-dismisser Link to comment
alfredpanda Posted September 26, 2022 Share Posted September 26, 2022 (edited) 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. 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 September 26, 2022 by alfredpanda Link to comment
kanera Posted February 5, 2023 Share Posted February 5, 2023 Runs well on Monterey (12.6) but I cannot get it to work on Ventura (13.2). ideas or pointers - thanks? Link to comment
sepulchra Posted February 5, 2023 Share Posted February 5, 2023 this script was updated and works: https://gist.github.com/lancethomps/a5ac103f334b171f70ce2ff983220b4f Link to comment
kanera Posted February 5, 2023 Share Posted February 5, 2023 Many thanks - does indeed work! 🙏 Link to comment
jackk Posted April 12, 2023 Author Share Posted April 12, 2023 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
Sorehead Posted May 4, 2023 Share Posted May 4, 2023 I'm not a programmer and don't understand how to use an apple script in Alfred. Could someone explain? Link to comment
Stephen_C Posted May 4, 2023 Share Posted May 4, 2023 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 rob213 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now