aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2014-07-03 14:15:14 +0200
committerGravatar Christian Hesse <mail@eworm.de>2014-07-03 14:15:14 +0200
commit0d6db7e0e2feed59d235e0a13cb0ea61afb63365 (patch)
tree2fa5720eb2f00657d380d3d4b21cced304ea71df
parentd555e73ce04bfc0d8aca92fc853277be7d439df8 (diff)
downloadjournal-notify-0d6db7e0e2feed59d235e0a13cb0ea61afb63365.tar.gz
journal-notify-0d6db7e0e2feed59d235e0a13cb0ea61afb63365.tar.zst
reinitialize libnotify on failure, give it three tries
-rw-r--r--journal-notify.c16
1 files 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(&regex, 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);