如何从终端清除通知中心?

如何从终端清除通知中心?

我很喜欢终端通知程序以及它如何允许您将内容发送到通知中心。

它甚至有一个方便的功能来删除发送,例如如果我欺骗来自另一个应用程序(如 CodeKit)的通知,语法是:

terminal-notifier -sender com.incident57.CodeKit -remove ALL

但我猜测该应用程序无法清除未发送的通知,因为其他消息仍然存在:

带阴影的屏幕截图.png

这是一个很棒的工具,但它仍然让我疑惑:

如何从终端清除通知中心?

答案1

你可以像这样运行 AppleScript:

osascript -e 'tell application "System Events" to tell process "Notification Center"
    click menu bar item 1 of menu bar 2
    delay 0.1
    repeat while exists button 1 of UI element 1 of row 2 of table 1 of scroll area 1 of window 1
        click button 1 of UI element 1 of row 2 of table 1 of scroll area 1 of window 1
    end repeat
    click menu bar item 1 of menu bar 2
end tell'

相关内容