当使用osascript -e“显示通知"时,更改通知图标. [英] Change icon of notification when using osascript -e "display notification"

查看:450
本文介绍了当使用osascript -e“显示通知"时,更改通知图标.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为emacs编写一个插件,该插件使用OS X的本机通知显示来显示通知.

I'm trying to write a plugin for emacs that displays a notification using OS X's native notification display.

我遇到了可以正常工作的terminal-notifier,但是它并不是在每台Mac上都起作用的依赖项.另外,应该使用户知道他们需要安装该软件包.

I've run into terminal-notifier which works, but it's a dependency that doesn't work on every mac. Plus the user should be made aware that they need to install the package.

我想做的是调用一个进程osascript -e并使其显示通知.问题是,更改其图标的唯一方法是从外部捆绑包中.有什么方法可以使osascript -e显示我想要的内容.

What I want to do is call a process osascript -e and make it display the notification. The problem is, the only way to change its icon is from an external bundle. Is there any way to make osascript -e display what I want.

启动sudo osascript似乎可以做到这一点,但这似乎是一个错误的设计,我还需要找到一种每次都可以传递root密码的方法.

starting sudo osascript seems to do that, but it seems to be bad design and I also need to find a way to pass the root password every single time.

推荐答案

您不能.这根本不是AppleScript公开的macOS功能.

You cannot. This is simply not a macOS feature exposed to AppleScript.

如果需要自定义图标,请考虑使用弹出式对话框"而不是通知中心"弹出式窗口.使用超时和按钮,您可以重新创建许多功能,尽管不能集成或美观.

If you need a custom icon, consider using a pop-up "dialog" rather than a Notification Center pop-up. With timeouts and buttons you can recreate much of the functionality, though not the integration nor aesthetics.

在显示对话框"中,如果要使用标准图标:0、1或2(停止,注意或注意),则可能没有osascript是显示图标的程序. Finder,例如:

In `display dialog', if you wish to use the standard icons: 0, 1, or 2 (stop, note, or caution), perhaps don't have osascript be the program that displays the icon. Finder, for example:

osascript -e 'tell application "Finder"' -e 'activate' -e 'display dialog "this is the note icon." with icon note' -e 'end tell'

或不带tell application…的情况下,您可以通过直接引用来使用您选择的图标,例如终端应用程序的图标:

or without the tell application… you may use an icon of your choice by referencing it directly, e.g. the Terminal app's icon:

osascript -e 'display dialog "Terminal icon" with icon alias "Macintosh HD:Applications:Utilities:Terminal.app:Contents:Resources:Terminal.icns"'

我不确定您的意思是什么,更改图标的唯一方法是从外部捆绑包中.是否有任何方法可以使osascript -e显示我想要的内容." 确切地说,您要吗?你尝试了什么?

I'm not sure what you mean by, "the only way to change its icon is from an external bundle. Is there any way to make osascript -e display what I want."  What, precisely, do you want? What have you tried?

这是显示对话框部分.

这篇关于当使用osascript -e“显示通知"时,更改通知图标.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆