summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile14
-rw-r--r--config.def.h19
-rw-r--r--journal-notify.c6
-rw-r--r--journal-notify.h1
4 files changed, 33 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index df16ebc..75c71ab 100644
--- a/Makefile
+++ b/Makefile
@@ -14,14 +14,17 @@ VERSION := 0.0.8
all: journal-notify README.html
+journal-notify: journal-notify.c journal-notify.h config.h version.h
+ $(CC) $(CFLAGS) -o journal-notify journal-notify.c
+
+config.h:
+ $(CP) config.def.h config.h
+
version.h: $(wildcard .git/HEAD .git/index .git/refs/tags/*) Makefile
echo "#ifndef VERSION" > $@
echo "#define VERSION \"$(shell git describe --tags --long 2>/dev/null || echo ${VERSION})\"" >> $@
echo "#endif" >> $@
-journal-notify: journal-notify.c journal-notify.h version.h
- $(CC) $(CFLAGS) -o journal-notify journal-notify.c
-
README.html: README.md
$(MD) README.md > README.html
@@ -42,7 +45,10 @@ install-doc: README.html
$(INSTALL) -D -m0644 screenshot.png $(DESTDIR)/usr/share/doc/journal-notify/screenshot.png
clean:
- rm -f *.o *~ README.html journal-notify
+ $(RM) -f *.o *~ README.html journal-notify version.h
+
+distclean:
+ $(RM) -f *.o *~ README.html journal-notify version.h config.h
release:
git archive --format=tar.xz --prefix=journal-notify-$(VERSION)/ $(VERSION) > journal-notify-$(VERSION).tar.xz
diff --git a/config.def.h b/config.def.h
new file mode 100644
index 0000000..333f848
--- /dev/null
+++ b/config.def.h
@@ -0,0 +1,19 @@
+/*
+ * (C) 2014-2015 by Christian Hesse <mail@eworm.de>
+ *
+ * This software may be used and distributed according to the terms
+ * of the GNU General Public License, incorporated herein by reference.
+ */
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+
+/* how long to display notifications */
+#define NOTIFICATION_TIMEOUT 10000
+
+/* throttle shreshold */
+#define THROTTLE_THRESHOLD 6
+
+#endif /* _CONFIG_H */
+
+// vim: set syntax=c:
diff --git a/journal-notify.c b/journal-notify.c
index 2d425be..024a7d5 100644
--- a/journal-notify.c
+++ b/journal-notify.c
@@ -303,10 +303,10 @@ int main(int argc, char **argv) {
if (have_regex == 0 || regexec(&regex, message, 0, NULL, 0) == 0) {
/* throttling */
notification_count++;
- if (notification_count >= 6) {
+ if (notification_count >= THROTTLE_THRESHOLD) {
if (verbose)
- fprintf(stderr, "Already showed %u notifications, throttling!\n", notification_count - 1);
- if (executeonly == 0 && notification_count == 6) {
+ fprintf(stderr, "This is the %uth notification, throttling!\n", notification_count);
+ if (executeonly == 0 && notification_count == THROTTLE_THRESHOLD) {
if ((rc = notify(program, "Throttling notification! View your journal for complete log.", 0, "dialog-warning", timeout)) > 0) {
fprintf(stderr, "Failed to show notification.\n");
}
diff --git a/journal-notify.h b/journal-notify.h
index d840236..0a6e0b4 100644
--- a/journal-notify.h
+++ b/journal-notify.h
@@ -23,6 +23,7 @@
#include <libnotify/notify.h>
+#include "config.h"
#include "version.h"
#define DEFAULTICON "dialog-information"