Milan Jurkulak
Milan Jurkulak

Reputation: 635

GJS Notification - no notification shown

I am working on one project, that will create notification from gjs script. There is no error, but notification is not shown. Any suggestion? Code:

#!/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);

Upvotes: 0

Views: 313

Answers (1)

andy.holmes
andy.holmes

Reputation: 3696

In order for a GNotification to be shown, you must have an associated .desktop file in either /usr/share/applications/ or ~/.local/share/applications/.

This file should have the X-GNOME-UsesNotifications key, and by convention would be named sk.project.app.desktop.

If sent without an icon set, the desktop will use the application icon defined in that file.

[Desktop Entry]
Type=Application
Name=My Application
Exec=/path/to/myapp.js
Terminal=false
Icon=sk.project.app
X-GNOME-UsesNotifications=true

Upvotes: 3

Related Questions