0
|
1 #include <libnotify/notify.h>
|
|
2 #include "notify.h"
|
|
3
|
|
4 #define NOTIFY_NAME "Software Update"
|
|
5
|
|
6 void init_notify()
|
|
7 {
|
|
8 notify_init(NOTIFY_NAME);
|
|
9 }
|
|
10
|
|
11 void send_notify(int normal, int critical)
|
|
12 {
|
|
13 NotifyNotification *ntfy;
|
|
14 char buf[128];
|
|
15 if (critical > 0) {
|
|
16 snprintf(buf, sizeof(buf), "There are %d software updates available, %d of them critical.", normal + critical, critical);
|
|
17 } else {
|
|
18 snprintf(buf, sizeof(buf), "There are %d software updates available.", normal);
|
|
19 }
|
|
20 ntfy = notify_notification_new(NOTIFY_NAME, buf, critical > 0 ? "software-update-urgent" : "software-update-available");
|
|
21 notify_notification_set_timeout(ntfy, 3000);
|
|
22 notify_notification_set_urgency(ntfy, critical > 0 ? NOTIFY_URGENCY_CRITICAL : NOTIFY_URGENCY_NORMAL);
|
|
23 notify_notification_show(ntfy, NULL);
|
|
24 }
|