如何通过命令行启动咆哮

发布于 2024-08-27 15:00:55 字数 302 浏览 9 评论 0原文

我有一个 bash 脚本,它使用 Growlnotify 发送通知。但是,如果 Growl 尚未运行,则 Growlnotify 不起作用,并且如果需要,它也不会自动启动 Growl。所以我希望能够检查 Growl 是否正在运行,如果没有运行则启动它。
我正在考虑做类似的事情:

g=$(ps -e | grep Growl | grep -v grep)
if [ -z "$g" ]  # Growl isn't running
then
# (start Growl)
fi

如何通过命令行启动 Growl?

I have a bash script that uses growlnotify to send notifications. However, growlnotify doesn't work if Growl isn't already running, and it won't auto start Growl if it needs it, either. So I want to be able to check if Growl is running, and then start it if it isn't.
I'm thinking of doing something like:

g=$(ps -e | grep Growl | grep -v grep)
if [ -z "$g" ]  # Growl isn't running
then
# (start Growl)
fi

How would I start Growl via the command line?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

转身泪倾城 2024-09-03 15:00:55

通常,Growl 安装程序将确保执行安装的用户获得一个登录启动项,该启动项启动 GrowlHelperApp.app(GrowlHelperApp.app)(Growl 的通知守护进程)。该应用程序内置于 Growl PreferencePane 中,因此您无法保证它将位于何处;它可能位于 /Library/PreferencePanes~/Library/PreferencePanes 中,具体取决于 Growl 的安装方式。如果您觉得不能相信用户会做正确的事情,您可以使用其包标识符以与位置无关的方式从命令行手动启动帮助程序应用程序:

open -b com.Growl.GrowlHelperApp

Normally the Growl installer will ensure that the user doing the installing gets a login Startup item that launches GrowlHelperApp.app, the notification daemon for Growl. The app is built into the Growl PreferencePane, so you can't guarantee where it will be located; it may be in /Library/PreferencePanes or ~/Library/PreferencePanes, depending on how Growl was installed. If you feel you can't trust the user to do the right thing, you can manually launch the helper app from the command line in a location-independent manner by using its bundle identifier:

open -b com.Growl.GrowlHelperApp
浅听莫相离 2024-09-03 15:00:55
pgrep growlnotify || growlnotify <options> &
pgrep growlnotify || growlnotify <options> &
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文