added format to rules

This commit is contained in:
Sascha Kruse 2011-11-15 01:21:08 +01:00
parent 4e7a12053d
commit 6d36786fc0
3 changed files with 13 additions and 10 deletions

View File

@ -21,18 +21,17 @@ char *key_string = "space"; /* set to NULL for no keybinging */
KeySym mask = ControlMask; KeySym mask = ControlMask;
/* KeySym mask = ControlMask || Mod4Mask */ /* KeySym mask = ControlMask || Mod4Mask */
int verbose = True; /* print info to stdout? */ int verbose = True; /* print info to stdout? */
const rule_t rules[] = { const rule_t rules[] = {
/* appname, summary, body, icon, timeout, urgency, fg, bg */ /* appname, summary, body, icon, timeout, urgency, fg, bg, format */
{ "notify-send", NULL, NULL, NULL, -1, -1, NULL, NULL }, { "notify-send", NULL, NULL, NULL, -1, -1, NULL, NULL, "%s %b" },
{ "Pidgin", NULL, NULL, NULL, -1, -1, NULL, NULL }, { "Pidgin", NULL, NULL, NULL, -1, -1, NULL, NULL, "%s %b" },
{ "Pidgin", "*signed on*", NULL, NULL, -1, LOW, NULL, NULL }, { "Pidgin", "*signed on*", NULL, NULL, -1, LOW, NULL, NULL, "%s %b" },
{ "Pidgin", "*signed off*", NULL, NULL, -1, LOW, NULL, NULL }, { "Pidgin", "*signed off*", NULL, NULL, -1, LOW, NULL, NULL, "%s %b" },
{ "Pidgin", "*says*", NULL, NULL, -1, CRIT, NULL, NULL }, { "Pidgin", "*says*", NULL, NULL, -1, CRIT, NULL, NULL, "%s %b" },
{ "Pidgin", "twitter.com*", NULL, NULL, -1, NORM, NULL, NULL }, { "Pidgin", "twitter.com*", NULL, NULL, -1, NORM, NULL, NULL, "%s %b" },
}; };

View File

@ -89,9 +89,10 @@ append(msg_queue_t *queue, msg_queue_t *new) {
msg_queue_t *last; msg_queue_t *last;
new->format = format;
apply_rules(new); 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("%s", new->summary, new->msg);
new->msg = string_replace("%i", new->icon, new->msg); new->msg = string_replace("%i", new->icon, new->msg);
new->msg = string_replace("%I", basename(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->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[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->color_strings[ColBG] = rules[i].bg ? rules[i].bg : msg->color_strings[ColBG];
msg->format = rules[i].format ? rules[i].format : msg->format;
} }
} }
} }

View File

@ -19,6 +19,7 @@ typedef struct _rule_t {
int urgency; int urgency;
char *fg; char *fg;
char *bg; char *bg;
const char *format;
} rule_t; } rule_t;
typedef struct _msg_queue_t { typedef struct _msg_queue_t {
@ -27,6 +28,7 @@ typedef struct _msg_queue_t {
char *body; char *body;
char *icon; char *icon;
char *msg; char *msg;
const char *format;
struct _msg_queue_t *next; struct _msg_queue_t *next;
time_t start; time_t start;
int timeout; int timeout;