Skip to content

Notifications

GNOME Shell provides implementations for freedesktop.org Notifications and GTK Notifications, serving as the notification server. These different implementations are usually hidden from application developers, who use the Gio.Notification abstraction to send notifications.

The GNOME Shell process itself is not a Gio.Application, and uses its own internal methods for showing notifications, bypassing the notification server. Extensions may also use these methods for displaying notifications.

Simple Notifications

Extensions that want to display a simple notification to the user, may use the method Main.notify().

js
import * as Main from 'resource:///org/gnome/shell/ui/main.js';


Main.notify('Title', 'Body');

If the notification is communicating an error to the user, the Main.notifyError() method will also log the notification as a warning.

js
import * as Main from 'resource:///org/gnome/shell/ui/main.js';


try {
    throw Error('File not found');
} catch (e) {
    Main.notifyError('Failed to load configuration', e.message);
}

The logged warning will appear similar to this:

sh
GNOME Shell-Message: 00:00:00.000: error: Failed to load configuration: File not found

MIT Licensed | GJS, A GNOME Project