GJS通知-未显示通知



我正在处理一个项目,该项目将从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);

为了显示GNotification,必须在/usr/share/applications/~/.local/share/applications/中有一个关联的.desktop文件。

这个文件应该有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

最新更新