#include "../toast.h"
#include <libnotify/notify.h>
#include <string.h>
#include <stdio.h>
#include <stdbool.h>
bool toastShow(const char *app,
const char *title,
const char *message,
const char *image_path)
{
if (!notify_is_initted() && !notify_init(app))
{
fprintf(stderr, "Failed to initialize libnotify\n");
return false;
}
NotifyNotification *notification = notify_notification_new(
title,
message,
(image_path && *image_path) ? image_path : NULL
);
if (!notification)
{
fprintf(stderr, "Failed to create notification\n");
return false;
}
notify_notification_set_timeout(notification, 8000);
notify_notification_set_urgency(notification, NOTIFY_URGENCY_NORMAL);
GError *error = NULL;
if (!notify_notification_show(notification, &error))
{
fprintf(stderr, "Failed to show notification: %s\n", error->message);
g_error_free(error);
g_object_unref(notification);
return false;
}
g_object_unref(notification);
return true;
}