GNotification API not working
// https://wiki.archlinux.org/index.php/Desktop_notifications#C
// hello_world.c
#include <gio/gio.h>
int main() {
GApplication *application = g_application_new ("hello.world", G_APPLICATION_FLAGS_NONE);
g_application_register (application, NULL, NULL);
GNotification *notification = g_notification_new ("Hello world!");
g_notification_set_body (notification, "This is an example notification.");
GIcon *icon = g_themed_icon_new ("dialog-information");
g_notification_set_icon (notification, icon);
g_application_send_notification (application, NULL, notification);
g_object_unref (icon);
g_object_unref (notification);
g_object_unref (application);
return 0;
}
gcc -o hello_world `pkg-config --cflags --libs gio-2.0` hello_world.c
I'm using an up-to-date Arch Linux distro. Upon execution, no notification pop-up is observed. No console output even when G_DEBUG=all G_MESSAGES_DEBUG=all
is set. The C++ snippet based on glibmm
doesn't work either.
The libnotify
C version on that arch wiki page works fine.
$ pacman -Qs 'glib2|glibmm|^gcc$|^gnome-shell$'
local/gcc 10.1.0-2 (base-devel)
The GNU Compiler Collection - C and C++ frontends
local/glib2 2.64.3-2
Low level core library
local/glibmm 2.64.2-1
C++ bindings for GLib
local/gnome-shell 1:3.36.3-1 (gnome)
Next generation desktop shell
Edited by Ce Sun