我正在研究一个项目,该项目将从gjs脚本创建通知。 没有错误,但未显示通知。 有什么建议吗? 代码:
#!/usr/bin/gjs
const Gio = imports.gi.Gio;
var Application = new Gio.Application({applicationId:"sk.project.app", flags:32});
var Notification = new Gio.Notification();
Notification.set_body("message here");
Application.send_notification(null, Notification);
答案 0 :(得分:3)
要显示GNotification,必须在.desktop
或/usr/share/applications/
中有一个关联的~/.local/share/applications/
文件。
此文件应具有X-GNOME-UsesNotifications
键,并且按照惯例将其命名为sk.project.app.desktop
。
如果发送时未设置图标,则桌面将使用该文件中定义的应用程序图标。
[Desktop Entry]
Type=Application
Name=My Application
Exec=/path/to/myapp.js
Terminal=false
Icon=sk.project.app
X-GNOME-UsesNotifications=true