Created
November 29, 2024 07:00
-
-
Save Strajk/4eccea362807627d7c0bae27e9d20ae2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Name: Clear MacOS notifications | |
| // Description: Only visible notifications – clearing not visible notifications is not possible | |
| import "@johnlindquist/kit" | |
| await jxa(` | |
| Application("System Events") | |
| .applicationProcesses.byName("NotificationCenter") | |
| .windows[0] | |
| .groups[0] | |
| .scrollAreas[0] | |
| .uiElements[0] | |
| .groups() | |
| .map(banner => banner.actions().slice(-1)[0]) | |
| .forEach(banner => banner.perform()) | |
| `) | |
| // Inspired by Kit's "applescript" function | |
| async function jxa(script: string) { | |
| await writeFile(kenvTmpPath("clear-macos-notifications.jxa"), script); | |
| await execa("osascript", ["-l", "JavaScript", kenvTmpPath("clear-macos-notifications.jxa")]); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment