From 6d36786fc04df106522d83b33e6a7dc31900c6a9 Mon Sep 17 00:00:00 2001 From: Sascha Kruse Date: Tue, 15 Nov 2011 01:21:08 +0100 Subject: [PATCH] added format to rules --- config.def.h | 17 ++++++++--------- dunst.c | 4 +++- dunst.h | 2 ++ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/config.def.h b/config.def.h index cd41ea7..ccff61c 100644 --- a/config.def.h +++ b/config.def.h @@ -21,20 +21,19 @@ char *key_string = "space"; /* set to NULL for no keybinging */ KeySym mask = ControlMask; /* KeySym mask = ControlMask || Mod4Mask */ - int verbose = True; /* print info to stdout? */ const rule_t rules[] = { - /* appname, summary, body, icon, timeout, urgency, fg, bg */ - { "notify-send", NULL, NULL, NULL, -1, -1, NULL, NULL }, - { "Pidgin", NULL, NULL, NULL, -1, -1, NULL, NULL }, - { "Pidgin", "*signed on*", NULL, NULL, -1, LOW, NULL, NULL }, - { "Pidgin", "*signed off*", NULL, NULL, -1, LOW, NULL, NULL }, - { "Pidgin", "*says*", NULL, NULL, -1, CRIT, NULL, NULL }, - { "Pidgin", "twitter.com*", NULL, NULL, -1, NORM, NULL, NULL }, + /* appname, summary, body, icon, timeout, urgency, fg, bg, format */ + { "notify-send", NULL, NULL, NULL, -1, -1, NULL, NULL, "%s %b" }, + { "Pidgin", NULL, NULL, NULL, -1, -1, NULL, NULL, "%s %b" }, + { "Pidgin", "*signed on*", NULL, NULL, -1, LOW, NULL, NULL, "%s %b" }, + { "Pidgin", "*signed off*", NULL, NULL, -1, LOW, NULL, NULL, "%s %b" }, + { "Pidgin", "*says*", NULL, NULL, -1, CRIT, NULL, NULL, "%s %b" }, + { "Pidgin", "twitter.com*", NULL, NULL, -1, NORM, NULL, NULL, "%s %b" }, }; - + #endif diff --git a/dunst.c b/dunst.c index 19c6ccc..56ef1b0 100644 --- a/dunst.c +++ b/dunst.c @@ -89,9 +89,10 @@ append(msg_queue_t *queue, msg_queue_t *new) { msg_queue_t *last; + new->format = format; apply_rules(new); - new->msg = string_replace("%a", new->appname, strdup(format)); + new->msg = string_replace("%a", new->appname, strdup(new->format)); new->msg = string_replace("%s", new->summary, new->msg); new->msg = string_replace("%i", new->icon, new->msg); new->msg = string_replace("%I", basename(new->icon), new->msg); @@ -130,6 +131,7 @@ apply_rules(msg_queue_t *msg) { msg->urgency = rules[i].urgency != -1 ? rules[i].urgency : msg->urgency; msg->color_strings[ColFG] = rules[i].fg ? rules[i].fg : msg->color_strings[ColFG]; msg->color_strings[ColBG] = rules[i].bg ? rules[i].bg : msg->color_strings[ColBG]; + msg->format = rules[i].format ? rules[i].format : msg->format; } } } diff --git a/dunst.h b/dunst.h index 3a8188c..8a4d9f9 100644 --- a/dunst.h +++ b/dunst.h @@ -19,6 +19,7 @@ typedef struct _rule_t { int urgency; char *fg; char *bg; + const char *format; } rule_t; typedef struct _msg_queue_t { @@ -27,6 +28,7 @@ typedef struct _msg_queue_t { char *body; char *icon; char *msg; + const char *format; struct _msg_queue_t *next; time_t start; int timeout;