From 0d6db7e0e2feed59d235e0a13cb0ea61afb63365 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 3 Jul 2014 14:15:14 +0200 Subject: reinitialize libnotify on failure, give it three tries --- journal-notify.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/journal-notify.c b/journal-notify.c index 63cc601..413f6d8 100644 --- a/journal-notify.c +++ b/journal-notify.c @@ -161,10 +161,20 @@ int main(int argc, char **argv) { /* show notification */ if (have_regex == 0 || regexec(®ex, message, 0, NULL, 0) == 0) { - if ((rc = notify(summary, message, icon)) < 0) { - fprintf(stderr, "Failed to show notification.\n"); - goto out40; + for (i = 0; i < 3; i++) { + if ((rc = notify(summary, message, icon)) == 0) + break; + + fprintf(stderr, "Failed to show notification, reinitializing libnotify.\n"); + notify_uninit(); + usleep(500 * 1000); + if (notify_init(program) == FALSE) { + fprintf(stderr, "Failed to initialize notify.\n"); + rc = EXIT_FAILURE; + } } + if (rc != 0) + goto out40; } free(summary); -- cgit v1.2.3-70-g09d2