aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--journal-notify.c24
2 files changed, 24 insertions, 2 deletions
diff --git a/README.md b/README.md
index d560bb5..446efcb 100644
--- a/README.md
+++ b/README.md
@@ -50,12 +50,14 @@ Be warned: This can flood your disktop with notifications.
`journal-notify` accepts some options:
+* *-a*: combine matches with a logical AND
* *-e*: use extended regular expressions
* *-h*: show help
* *-i ICON*: icon to use
* *-m MATCH*: This can be specified more than once. The option accepts matches
to systemd journal fields. (see `man 7 systemd.journal-fields`)
* *-n*: no case sensitive regular expressions
+* *-o*: combine matches with a logical OR
* *-r REGEX*: This add a regular expression match for the message field.
* *-v* verbose output, can be specified multiple times
diff --git a/journal-notify.c b/journal-notify.c
index 0f54090..bc7740c 100644
--- a/journal-notify.c
+++ b/journal-notify.c
@@ -18,7 +18,7 @@
const char * program = NULL;
-#define OPTSTRING "ehi:m:nr:v"
+#define OPTSTRING "aehi:m:nor:v"
#define DEFAULTICON "dialog-information"
int notify(const char * summary, const char * body, const char * icon) {
@@ -71,7 +71,7 @@ int main(int argc, char **argv) {
regex_flags |= REG_EXTENDED;
break;
case 'h':
- fprintf(stderr, "usage: %s [-e] [-h] [-i ICON] [-m MATCH] [-n] [-r REGEX] [-vv]\n", program);
+ fprintf(stderr, "usage: %s [-e] [-h] [-i ICON] [-m MATCH] [-o -m MATCH] [-a -m MATCH] [-n] [-r REGEX] [-vv]\n", program);
return EXIT_SUCCESS;
case 'n':
regex_flags |= REG_ICASE;
@@ -98,6 +98,16 @@ int main(int argc, char **argv) {
/* get command line options - part II*/
while ((i = getopt(argc, argv, OPTSTRING)) != -1) {
switch (i) {
+ case 'a':
+ if (verbose > 1)
+ printf("Adding logical AND to match...\n");
+
+ if ((rc = sd_journal_add_conjunction(journal)) < 0) {
+ fprintf(stderr, "Failed to add logical AND to match.\n");
+ goto out20;
+ }
+
+ break;
case 'i':
icon = optarg;
break;
@@ -111,6 +121,16 @@ int main(int argc, char **argv) {
}
break;
+ case 'o':
+ if (verbose > 1)
+ printf("Adding logical OR to match...\n");
+
+ if ((rc = sd_journal_add_disjunction(journal)) < 0) {
+ fprintf(stderr, "Failed to add logical OR to match.\n");
+ goto out20;
+ }
+
+ break;
case 'r':
if (verbose > 1)
printf("Adding regular expression '%s'...\n", optarg);