Add 'msg_urgency' as a new filter to match on the urgency.
This patch adds a new filter 'msg_urgency' which _matches_ on the urgency on the notification. This allows to configure different notification parameters/scripts to different urgency levels.
This commit is contained in:
parent
2638178e5a
commit
431c65fc76
14
config.def.h
14
config.def.h
@ -83,11 +83,11 @@ keyboard_shortcut context_ks = {.str = "none",
|
|||||||
rule_t default_rules[] = {
|
rule_t default_rules[] = {
|
||||||
/* name can be any unique string. It is used to identify the rule in dunstrc to override it there */
|
/* name can be any unique string. It is used to identify the rule in dunstrc to override it there */
|
||||||
|
|
||||||
/* name, appname, summary, body, icon, timeout, urgency, fg, bg, format, script */
|
/* name, appname, summary, body, icon, msg_urgency, timeout, urgency, fg, bg, format, script */
|
||||||
{"empty", NULL, NULL, NULL, NULL, -1, -1, NULL, NULL, NULL, NULL},
|
{ "empty", NULL, NULL, NULL, NULL, -1, -1, -1, NULL, NULL, NULL, NULL},
|
||||||
/* { "rule1", "notify-send", NULL, NULL, NULL, -1, -1, NULL, NULL, "%s %b", NULL }, */
|
/* { "rule1", "notify-send", NULL, NULL, NULL, -1, -1, -1, NULL, NULL, "%s %b", NULL }, */
|
||||||
/* { "rule2", "Pidgin", "*says*, NULL, NULL, -1, CRITICAL, NULL, NULL, NULL, NULL }, */
|
/* { "rule2", "Pidgin", "*says*, NULL, NULL, -1, -1, CRITICAL, NULL, NULL, NULL, NULL }, */
|
||||||
/* { "rule3", "Pidgin", "*signed on*", NULL, NULL, -1, LOW, NULL, NULL, NULL, NULL }, */
|
/* { "rule3", "Pidgin", "*signed on*", NULL, NULL, -1, -1, LOW, NULL, NULL, NULL, NULL }, */
|
||||||
/* { "rule4", "Pidgin", "*signed off*", NULL, NULL, -1, LOW, NULL, NULL, NULL, NULL }, */
|
/* { "rule4", "Pidgin", "*signed off*", NULL, NULL, -1, -1, LOW, NULL, NULL, NULL, NULL }, */
|
||||||
/* { "rule5", NULL, "*foobar*", NULL, NULL, -1, -1, NULL, "#00FF00", NULL, NULL }, */
|
/* { "rule5", NULL, "*foobar*", NULL, NULL, -1, -1, -1, NULL, "#00FF00", NULL, NULL }, */
|
||||||
};
|
};
|
||||||
|
6
dunstrc
6
dunstrc
@ -183,9 +183,9 @@
|
|||||||
|
|
||||||
# Every section that isn't one of the above is interpreted as a rules to
|
# Every section that isn't one of the above is interpreted as a rules to
|
||||||
# override settings for certain messages.
|
# override settings for certain messages.
|
||||||
# Messages can be matched by "appname", "summary", "body" or "icon" and
|
# Messages can be matched by "appname", "summary", "body", "icon",
|
||||||
# you can override the "timeout", "urgency", "foreground", "background"
|
# "msg_urgency" and you can override the "timeout", "urgency", "foreground",
|
||||||
# and "format".
|
# "background" and "format".
|
||||||
# Shell-like globbing will get expanded.
|
# Shell-like globbing will get expanded.
|
||||||
#
|
#
|
||||||
# SCRIPTING
|
# SCRIPTING
|
||||||
|
4
rules.c
4
rules.c
@ -48,6 +48,7 @@ void rule_init(rule_t * r)
|
|||||||
r->summary = NULL;
|
r->summary = NULL;
|
||||||
r->body = NULL;
|
r->body = NULL;
|
||||||
r->icon = NULL;
|
r->icon = NULL;
|
||||||
|
r->msg_urgency = -1;
|
||||||
r->timeout = -1;
|
r->timeout = -1;
|
||||||
r->urgency = -1;
|
r->urgency = -1;
|
||||||
r->fg = NULL;
|
r->fg = NULL;
|
||||||
@ -64,6 +65,7 @@ bool rule_matches_notification(rule_t * r, notification * n)
|
|||||||
return ((!r->appname || !fnmatch(r->appname, n->appname, 0))
|
return ((!r->appname || !fnmatch(r->appname, n->appname, 0))
|
||||||
&& (!r->summary || !fnmatch(r->summary, n->summary, 0))
|
&& (!r->summary || !fnmatch(r->summary, n->summary, 0))
|
||||||
&& (!r->body || !fnmatch(r->body, n->body, 0))
|
&& (!r->body || !fnmatch(r->body, n->body, 0))
|
||||||
&& (!r->icon || !fnmatch(r->icon, n->icon, 0)));
|
&& (!r->icon || !fnmatch(r->icon, n->icon, 0))
|
||||||
|
&& (r->msg_urgency == -1 || r->msg_urgency == n->urgency));
|
||||||
}
|
}
|
||||||
/* vim: set ts=8 sw=8 tw=0: */
|
/* vim: set ts=8 sw=8 tw=0: */
|
||||||
|
1
rules.h
1
rules.h
@ -13,6 +13,7 @@ typedef struct _rule_t {
|
|||||||
char *summary;
|
char *summary;
|
||||||
char *body;
|
char *body;
|
||||||
char *icon;
|
char *icon;
|
||||||
|
int msg_urgency;
|
||||||
|
|
||||||
/* actions */
|
/* actions */
|
||||||
int timeout;
|
int timeout;
|
||||||
|
39
settings.c
39
settings.c
@ -31,6 +31,27 @@ static void parse_follow_mode(const char *mode)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ini_get_urgency(char *section, char *key, int def)
|
||||||
|
{
|
||||||
|
int ret = def;
|
||||||
|
char *urg = ini_get_string(section, key, "");
|
||||||
|
|
||||||
|
if (strlen(urg) > 0) {
|
||||||
|
if (strcmp(urg, "low") == 0)
|
||||||
|
ret = LOW;
|
||||||
|
else if (strcmp(urg, "normal") == 0)
|
||||||
|
ret = NORM;
|
||||||
|
else if (strcmp(urg, "critical") == 0)
|
||||||
|
ret = CRIT;
|
||||||
|
else
|
||||||
|
fprintf(stderr,
|
||||||
|
"unknown urgency: %s, ignoring\n",
|
||||||
|
urg);
|
||||||
|
free(urg);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void load_settings(char *cmdline_config_path)
|
void load_settings(char *cmdline_config_path)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -291,22 +312,8 @@ void load_settings(char *cmdline_config_path)
|
|||||||
r->body = ini_get_string(cur_section, "body", r->body);
|
r->body = ini_get_string(cur_section, "body", r->body);
|
||||||
r->icon = ini_get_string(cur_section, "icon", r->icon);
|
r->icon = ini_get_string(cur_section, "icon", r->icon);
|
||||||
r->timeout = ini_get_int(cur_section, "timeout", r->timeout);
|
r->timeout = ini_get_int(cur_section, "timeout", r->timeout);
|
||||||
{
|
r->urgency = ini_get_urgency(cur_section, "urgency", r->urgency);
|
||||||
char *urg = ini_get_string(cur_section, "urgency", "");
|
r->msg_urgency = ini_get_urgency(cur_section, "msg_urgency", r->msg_urgency);
|
||||||
if (strlen(urg) > 0) {
|
|
||||||
if (strcmp(urg, "low") == 0)
|
|
||||||
r->urgency = LOW;
|
|
||||||
else if (strcmp(urg, "normal") == 0)
|
|
||||||
r->urgency = NORM;
|
|
||||||
else if (strcmp(urg, "critical") == 0)
|
|
||||||
r->urgency = CRIT;
|
|
||||||
else
|
|
||||||
fprintf(stderr,
|
|
||||||
"unknown urgency: %s, ignoring\n",
|
|
||||||
urg);
|
|
||||||
free(urg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
r->fg = ini_get_string(cur_section, "foreground", r->fg);
|
r->fg = ini_get_string(cur_section, "foreground", r->fg);
|
||||||
r->bg = ini_get_string(cur_section, "background", r->bg);
|
r->bg = ini_get_string(cur_section, "background", r->bg);
|
||||||
r->format = ini_get_string(cur_section, "format", r->format);
|
r->format = ini_get_string(cur_section, "format", r->format);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user