【问题标题】:Command-line utility to send notifications to Notification Center in Mountain Lion用于向 Mountain Lion 中的通知中心发送通知的命令行实用程序
【发布时间】:2012-07-31 10:53:34
【问题描述】:

是否有任何命令行实用程序可以向通知中心发送通知?类似于 Growl 的 growlnotify

【问题讨论】:

    标签: macos command-line notifications


    【解决方案1】:

    【讨论】:

      【解决方案2】:

      在 Maverics 中可以触发来自 Apple 脚本的通知,但不确定它是否适用于 Mountain Lion:

      display notification "Hello!"
      

      我制作了一个简单的命令行脚本来将参数传递给苹果脚本。一站式安装:

      echo -e '#!/bin/bash\n/usr/bin/osascript -e "display notification \"$*\""'|sudo -s "cd /usr/local/bin;tee notify&&chmod +x notify"
      

      将下面的代码输出到/usr/local/bin(必须存在)并添加可执行标志。确保 /usr/local/bin 在你的 $PATH 中。

      #! /bin/bash
      /usr/bin/osascript -e "display notification \"$*\""
      

      现在显示通知:

      notify "Lorem ipsum dolor sit amet"
      sleep 5 ; notify "Slow command finished"
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-07-27
        • 2012-07-21
        • 2012-08-25
        • 1970-01-01
        • 2012-07-27
        • 2021-04-18
        • 1970-01-01
        • 2019-08-25
        相关资源
        最近更新 更多