Linux具有notify-send
将用户通知发送到桌面管理器的命令.(在许多环境中,这些显示为屏幕一角的弹出窗口,以及低电量警告和其他系统消息.)我在监视和备份脚本中使用它.
Cygwin似乎没有lib-notify,那么这个命令是否有Windows等价物?网络搜索引导我找到关于从Windows系统托盘/通知区域运行批处理文件的文章,或尝试从批处理文件中清理系统托盘,但我还没有找到一种方法从后台进程生成不显眼的用户消息.
我收到这个错误。知道出了什么问题吗?
from gi.repository import Notify
Notify.init("App Name")
Notify.Notification.new("Hi").show()
GLib.Error: g-dbus-error-quark: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Notifications was not provided by any .service files
Run Code Online (Sandbox Code Playgroud)
(在 Raspberry Pi 上使用最新的 Raspbian)
有没有人知道如何通过notify-send发送多个弹出窗口一次显示在屏幕上.
附:
$ notify-send 'Message One' 'Body One' & notify-send 'Message Two' 'Body Two' & notify-send 'Message Three' 'Body Three'
Run Code Online (Sandbox Code Playgroud)
每个人等待队列中的前一个弹出窗口在显示之前到期,我试图让所有三个人尽快在屏幕上向下级联.
男人说:
OPTIONS
-u, --urgency=LEVEL Specifies the urgency level (low, normal, critical).
-t, --expire-time=TIME
Specifies the timeout in milliseconds at which to expire the notification.
-i, --icon=ICON[,ICON...]
Specifies an icon filename or stock icon to display.
-c, --category=TYPE[,TYPE...]
Specifies the notification category.
Help options:
-?, --help
Show this help message
-h, --hint=TYPE:NAME:VALUE
Specifies basic extra data to pass. Valid types …
Run Code Online (Sandbox Code Playgroud) 我发现以下消息在我的 system.log 中重复多次(约 5 次/分钟)macos x
:
Apr 5 12:23:52 macbook-air Google Chrome Helper[8216]:
Libnotify: notify_register_coalesced_registration failed with code 9 on line 2835
Run Code Online (Sandbox Code Playgroud)
这是什么意思?我能做些什么来修复它并停止在我的日志文件中显示消息?
我在Ruby GTK应用程序中使用ruby-libnotify,它可以很好地在Ubuntu中创建一个气泡弹出窗口.我在哈代,这一切都很棒.然后我让其他人在Jaunty上尝试应用程序,而不是像我预期的那样使用新的Notify-OSD系统的气泡弹出窗口,通知变成了一个对话框.
我调查了一下,发现Ubuntu wiki说问题是因为我设置了0的超时:
某些程序指定expire_timeout为0以生成永远不会自行关闭的通知,假设它们可以像在notification-daemon中一样手动关闭.由于这通常是针对需要响应或确认的消息进行的,因此Notify OSD将其显示为警告框而不是泡泡.
有没有办法我可以通过某种方式使用libnotify来获得具有"永不过期"超时的正常气泡?如果我可以使用旧的通知系统,我实际上更喜欢它,因为Notify-OSD似乎根本不支持永久性气泡.
为我设置对话框是不可接受的,因为它不会停留在所有窗口上,因此用户不会立即看到弹出窗口(这是使用气泡弹出窗口的全部要点).
我正在使用libnotify库在Ubuntu中显示通知.我想要显示某种电池(因为我的应用程序是电池表).
我可以使用的图标类型是:
指定图标文件名的URI(例如file://path/to/my-icon.png)
一个'股票'图标名称.一个会成功调用gtk_icontheme_lookup()(例如'stock-delete')注意:这些不一定是普通的GTK股票图标 - 任何主题图标都可以.
一个pixbuf
我理想情况下喜欢使用选项#2,但是我找不到可用图标的名称.如何找到可用的图标?
我有一个Python 3脚本,从URL获取一些JSON,处理它,并通知我,如果我得到的数据有任何重大变化.我尝试过使用notify2和PyGObject的libnotify绑定(gi.repository.Notify),并用这两种方法得到类似的结果.当我从终端运行它时,这个脚本工作正常,但是当cron尝试运行它时会窒息.
import notify2
from gi.repository import Notify
def notify_pygobject(new_stuff):
Notify.init('My App')
notify_str = '\n'.join(new_stuff)
print(notify_str)
popup = Notify.Notification.new('Hey! Listen!', notify_str,
'dialog-information')
popup.show()
def notify_notify2(new_stuff):
notify2.init('My App')
notify_str = '\n'.join(new_stuff)
print(notify_str)
popup = notify2.Notification('Hey! Listen!', notify_str,
'dialog-information')
popup.show()
Run Code Online (Sandbox Code Playgroud)
现在,如果我创建一个notify_pygobject
使用字符串列表调用的脚本,cron会通过邮件假脱机将此错误抛回给我:
Traceback (most recent call last):
File "/home/p0lar_bear/Documents/devel/notify-test/test1.py", line 3, in <module>
main()
File "/home/p0lar_bear/Documents/devel/notify-test/test1.py", line 4, in main
testlib.notify(notify_projects)
File "/home/p0lar_bear/Documents/devel/notify-test/testlib.py", line 8, in notify
popup.show()
File "/usr/lib/python3/dist-packages/gi/types.py", line 113, in function
return info.invoke(*args, **kwargs) …
Run Code Online (Sandbox Code Playgroud) 我正在Linux下编写一个小的Python脚本,该脚本会libnotify
通过使用以下语法弹出许多弹出窗口:
import os
os.execv('/usr/bin/notify-send', ['App Title', 'Message'])
Run Code Online (Sandbox Code Playgroud)
不幸的是,由于某种奇怪的原因,它杀死了解释器,直到命令提示符。
它不会与脚本执行的任何其他命令一起执行此操作notify-send
。
没有给出任何错误,没有引发任何已知的异常,没有任何错误的迹象,它只会消失在命令提示符下。
是否有人有同样容易做到的建议或替代方案?
我无法在Firefox上激活Twitter网络通知,您可以在下面的屏幕截图中看到