Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ftabashir/b94336c7d4a21c4cd22433c332f69984 to your computer and use it in GitHub Desktop.
Save ftabashir/b94336c7d4a21c4cd22433c332f69984 to your computer and use it in GitHub Desktop.
#!/usr/bin/osascript
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Close all background items added notifications
# @raycast.mode compact
# Optional parameters:
# @raycast.icon 🔕
tell application "System Events"
tell process "NotificationCenter"
set frontmost to true
set numwins to (count windows)
repeat with i from numwins to 1 by -1
tell window i
set numg to (count group)
repeat with j from numg to 1 by -1
tell scroll area of group j
tell every UI element of first UI element
set cc to (every UI element whose Value is "Background Items Added")
if count of cc is 1
perform action "AXPress"
end if
end tell
end tell
end repeat
end tell
end repeat
end tell
end tell
@ftabashir
Copy link
Author

Unfortunately I didn't find a way to close notifications, instead this script simply clicks them. So a settings window will appear after running this script.
If you know a way to fix this, please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment