单击咆哮通知即可启动应用程序
使用 bash/shell 脚本,我有咆哮通知,告诉我何时登录尝试失败,并在咆哮通知中显示坐在计算机前的人的图片。有没有办法可以使用growlnotify启动预览以在单击通知时显示图片?
Using bash/shell scripting I have growlnotify telling me when there was a failed login attempt, and displaying the a picture of whoever was sitting in front of the computer in a growl notification. Is there a way that I can use growlnotify to launch preview to display the picture when the notification is clicked?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以做的一件事是将
--url
选项传递给growlnotify
。采用 Vaz 的示例:
请注意,我从参数中删除了
-w
随后的open
命令。由于我们使用的是--url
,因此growlnotify
会自行处理回调。您不需要暂停执行,此方法可能会解决 Vaz 暴露的多个通知的问题。通过将file://...
字符串传递给--url
,growlnotify
在单击后会在系统默认应用程序中打开引用的文件通知。最后的陷阱:只有当您向其传递以
http://
开头的字符串时,--url
才会正确处理 url。 “google.com”或“www.google.com”将不起作用。文件系统结构也是如此,您必须提供类似file:///Users/you/Pictures/cats.jpg
的内容。这个功能从 1.4 版本开始就可以使用,但是,根据我的检查,
man
中缺少它。资料来源:
https://code.google.com/p/growl/issues/详情?id=341
https://groups.google.com/d/msg/growldiscuss/nUdYxOevkxI/ oYjxdhSEi98J
希望有帮助!
One thing you could do would be to pass a
--url
option togrowlnotify
.Picking up Vaz's example:
Note that I removed
-w
from the parameters as well as theopen
command that followed. Since we're using--url
,growlnotify
handles the callback on its own. You don't need to pause the execution and this method will probably solve the issue Vaz has exposed for multiple notifications. By passing afile://...
string to the--url
,growlnotify
opens the referred file in the system's default application after clicking the notification.A final gotcha:
--url
will only handle url's correctly if you pass it a string starting withhttp://
. "google.com" or "www.google.com" won't work. The same goes for your filesystem structure, you have to provide something likefile:///Users/you/Pictures/cats.jpg
.This feature has been available since version 1.4, but, from what I've checked, it's missing from the
man
.Sources:
https://code.google.com/p/growl/issues/detail?id=341
https://groups.google.com/d/msg/growldiscuss/nUdYxOevkxI/oYjxdhSEi98J
Hope it helps!
这是一种方法:这样做的
主要问题是,如果出现多个通知,单击一个通知将导致所有阻止的growlnotify子shell解除阻止(一次打开所有图片)。由于某种原因,这似乎是咆哮的标准行为。这可能不是一个真正的问题,除非它的行为不如正确排队它们那样好(我尝试用一些递归子外壳作业控制疯狂来做到这一点,但我不认为 bash 会让我这样做。 .. 当然有一种更复杂的方法可以将它们实际排队。)
Here's one way to do it:
The main problem with this is that if more than one notification comes up, clicking one will cause all the blocking growlnotify subshells to unblock (opening all the pics at once). This seems to be standard behaviour for growl for some reason. That might not really be an issue except it doesn't behave as nicely as it would if it queued them up properly (I tried to do this with some recursive subshell job control craziness but I don't think bash will let me do it... there's certainly a more involved way it could be done to actually queue them up.)