如何通过命令行启动咆哮
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常,Growl 安装程序将确保执行安装的用户获得一个登录启动项,该启动项启动 GrowlHelperApp.app(GrowlHelperApp.app)(Growl 的通知守护进程)。该应用程序内置于 Growl PreferencePane 中,因此您无法保证它将位于何处;它可能位于
/Library/PreferencePanes
或~/Library/PreferencePanes
中,具体取决于 Growl 的安装方式。如果您觉得不能相信用户会做正确的事情,您可以使用其包标识符以与位置无关的方式从命令行手动启动帮助程序应用程序: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: