Notifications

GNOME Shell provides implementations for freedesktop.org Notificationsopen in new window and GTK Notificationsopen in new window, serving as the notification server. These different implementations are usually hidden from application developers, who use the Gio.Notificationopen in new window 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().

const Main = imports.ui.main;


Main.notify('Title', 'Body');
1
2
3
4

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

const Main = imports.ui.main;


try {
    throw Error('File not found');
} catch (e) {
    Main.notifyError('Failed to load configuration', e.message);
}
1
2
3
4
5
6
7
8

The logged warning will appear similar to this:

GNOME Shell-Message: 00:00:00.000: error: Failed to load configuration: File not found
1
Last Updated: 7/12/2023, 10:26:26 PM
Contributors: Andy Holmes