From 37fbb9fa23885064df9f2fa92c0308184cab4fda Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 23 Jun 2015 10:55:01 +0200 Subject: throttle matched entries only --- journal-notify.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/journal-notify.c b/journal-notify.c index 8e68ea2..2d425be 100644 --- a/journal-notify.c +++ b/journal-notify.c @@ -258,19 +258,7 @@ int main(int argc, char **argv) { gettimeofday(&tv_now, NULL); - if (tv_now.tv_sec == tv_last.tv_sec) { - notification_count++; - if (notification_count >= 5) { - if (verbose) - fprintf(stderr, "Already showed %u notifications, throttling!\n", notification_count); - if (executeonly == 0 && notification_count == 5) { - if ((rc = notify(program, "Throttling notification! View your journal for complete log.", 0, "dialog-warning", timeout)) > 0) { - fprintf(stderr, "Failed to show notification.\n"); - } - } - continue; - } - } else { + if (tv_now.tv_sec != tv_last.tv_sec) { tv_last = tv_now; notification_count = 0; } @@ -313,6 +301,19 @@ int main(int argc, char **argv) { printf("Received message from journal: %s\n", message); if (have_regex == 0 || regexec(®ex, message, 0, NULL, 0) == 0) { + /* throttling */ + notification_count++; + if (notification_count >= 6) { + if (verbose) + fprintf(stderr, "Already showed %u notifications, throttling!\n", notification_count - 1); + if (executeonly == 0 && notification_count == 6) { + if ((rc = notify(program, "Throttling notification! View your journal for complete log.", 0, "dialog-warning", timeout)) > 0) { + fprintf(stderr, "Failed to show notification.\n"); + } + } + continue; + } + /* show notification */ if (executeonly == 0) { for (i = 0; i < 3; i++) { -- cgit v1.2.3-70-g09d2