diff options
author | Christian Hesse <mail@eworm.de> | 2015-06-23 12:22:53 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2015-06-23 12:22:53 +0200 |
commit | 011989fbb773a1568be6d8609fb821ea8e62fb0f (patch) | |
tree | 74015b49d0d7c7d9a65df2c3242f6477aab207fe | |
parent | 37fbb9fa23885064df9f2fa92c0308184cab4fda (diff) | |
download | journal-notify-011989fbb773a1568be6d8609fb821ea8e62fb0f.tar.gz journal-notify-011989fbb773a1568be6d8609fb821ea8e62fb0f.tar.zst |
introduce config.h
-rw-r--r-- | Makefile | 14 | ||||
-rw-r--r-- | config.def.h | 19 | ||||
-rw-r--r-- | journal-notify.c | 6 | ||||
-rw-r--r-- | journal-notify.h | 1 |
4 files changed, 33 insertions, 7 deletions
@@ -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(®ex, 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" |