aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2015-06-23 10:55:01 +0200
committerGravatar Christian Hesse <mail@eworm.de>2015-06-23 10:55:01 +0200
commit37fbb9fa23885064df9f2fa92c0308184cab4fda (patch)
treec7e3da3b7e253accba8311a461fb495cc2e222e4
parent493b81ead774a72bcf99d74a408db4aefa74f1b3 (diff)
downloadjournal-notify-37fbb9fa23885064df9f2fa92c0308184cab4fda.tar.gz
journal-notify-37fbb9fa23885064df9f2fa92c0308184cab4fda.tar.zst
throttle matched entries only
-rw-r--r--journal-notify.c27
1 files 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(&regex, 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++) {