bash 如何通过命令行启动咆哮
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2564761/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to start growl via the command line
提问by nightfire
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:
我有一个 bash 脚本,它使用 gurlnotify 发送通知。但是,如果 Growl 尚未运行,growlnotify 将不起作用,并且如果需要它也不会自动启动 Growl。所以我希望能够检查 Growl 是否正在运行,如果不是,则启动它。
我正在考虑做类似的事情:
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?
我将如何通过命令行启动 Growl?
回答by Ned Deily
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/PreferencePanesor ~/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:
通常,Growl 安装程序将确保执行安装的用户获得一个登录启动项GrowlHelperApp.app,该启动项是Growl 的通知守护程序。该应用程序内置于 Growl PreferencePane 中,因此您无法保证它将位于何处;它可能在/Library/PreferencePanes或 中~/Library/PreferencePanes,具体取决于 Growl 的安装方式。如果你觉得你不能相信用户会做正确的事情,你可以使用它的包标识符以与位置无关的方式从命令行手动启动帮助应用程序:
open -b com.Growl.GrowlHelperApp
回答by ghostdog74
pgrep growlnotify || growlnotify <options> &

