0

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);
Milan Jurkulak
  • 557
  • 3
  • 6

1 Answers1

3

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
andy.holmes
  • 3,383
  • 17
  • 28