【问题标题】:GJS Notification - no notification shownGJS 通知 - 未显示通知
【发布时间】:2020-07-17 20:40:59
【问题描述】:

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

【问题讨论】:

    标签: notifications gio gjs


    【解决方案1】:

    为了显示 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
    

    【讨论】:

      猜你喜欢
      • 2019-08-21
      • 2017-12-12
      • 2013-04-09
      • 1970-01-01
      • 1970-01-01
      • 2021-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多