view notify.c @ 0:f5e03fc667f8

initial commit
author Pavol Rusnak <stick@gk2.sk>
date Mon, 26 Sep 2011 18:52:04 +0200
parents
children 847ae02bc13b
line wrap: on
line source

#include <libnotify/notify.h>
#include "notify.h"

#define NOTIFY_NAME "Software Update"

void init_notify()
{
	notify_init(NOTIFY_NAME);
}

void send_notify(int normal, int critical)
{
	NotifyNotification *ntfy;
	char buf[128];
	if (critical > 0) {
		snprintf(buf, sizeof(buf), "There are %d software updates available, %d of them critical.", normal + critical, critical);
	} else {
		snprintf(buf, sizeof(buf), "There are %d software updates available.", normal);
	}
	ntfy = notify_notification_new(NOTIFY_NAME, buf, critical > 0 ? "software-update-urgent" : "software-update-available");
	notify_notification_set_timeout(ntfy, 3000);
	notify_notification_set_urgency(ntfy, critical > 0 ? NOTIFY_URGENCY_CRITICAL : NOTIFY_URGENCY_NORMAL);
	notify_notification_show(ntfy, NULL);
}