4 #include <sys/inotify.h>
5 #include <notification.h>
7 #include <libwlmessage.h>
13 void sigint_handler (int s)
15 inotify_rm_watch (fd, wd);
20 void display_notifications ()
22 notification_h noti = NULL;
23 notification_list_h notification_list = NULL;
24 notification_list_h get_list = NULL;
29 char *image_path = NULL;
31 notification_get_list (NOTIFICATION_TYPE_NOTI, -1, ¬ification_list);
32 if (notification_list) {
33 get_list = notification_list_get_head (notification_list);
35 noti = notification_list_get_data (get_list);
36 notification_get_pkgname (noti, &pkgname);
38 notification_get_application (noti, &pkgname);
39 notification_get_title (noti, &title, NULL);
40 notification_get_text (noti, NOTIFICATION_TEXT_TYPE_CONTENT, &content);
41 notification_get_image (noti, NOTIFICATION_IMAGE_TYPE_ICON, &image_path);
44 struct wlmessage *wlmessage = wlmessage_create ();
45 wlmessage_set_title (wlmessage, title);
46 wlmessage_set_icon (wlmessage, image_path);
47 wlmessage_set_message (wlmessage, content);
48 wlmessage_add_button (wlmessage, 0, "Ok");
49 wlmessage_show (wlmessage, NULL);
50 wlmessage_destroy (wlmessage);
53 notification_delete (noti);
58 int main (int argc, char **argv)
62 /* display notifications once, so it stays useful without inotify */
63 display_notifications ();
67 fprintf (stderr, "ERROR: cannot initialize inotify\n");
68 fprintf (stderr, "Verify that your kernel integrates it\n");
72 signal (SIGINT, sigint_handler);
73 wd = inotify_add_watch (fd, "/usr/dbspace/.notification.db", IN_MODIFY);
75 read (fd, buffer, sizeof(buffer));
76 display_notifications ();