Merge branch 'match_msg_urgency' of git://github.com/wavexx/dunst into pull_requests
This commit is contained in:
		
						commit
						54c1b58cb0
					
				
							
								
								
									
										14
									
								
								config.def.h
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								config.def.h
									
									
									
									
									
								
							| @ -83,11 +83,11 @@ keyboard_shortcut context_ks = {.str = "none", | ||||
| rule_t default_rules[] = { | ||||
|         /* 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 */ | ||||
|         {"empty", NULL, NULL, NULL, NULL, -1, -1, NULL, NULL, NULL, NULL}, | ||||
|         /* { "rule1", "notify-send",  NULL,            NULL,  NULL,  -1,       -1,       NULL,  NULL, "%s %b", NULL }, */ | ||||
|         /* { "rule2", "Pidgin",       "*says*,         NULL,  NULL,  -1,       CRITICAL, NULL,  NULL, NULL, NULL    }, */ | ||||
|         /* { "rule3", "Pidgin",       "*signed on*",   NULL,  NULL,  -1,       LOW,      NULL,  NULL, NULL, NULL    }, */ | ||||
|         /* { "rule4", "Pidgin",       "*signed off*",  NULL,  NULL,  -1,       LOW,      NULL,  NULL, NULL, NULL    }, */ | ||||
|         /* { "rule5", NULL,           "*foobar*",      NULL,  NULL,  -1,       -1,       NULL,  "#00FF00", NULL, NULL }, */ | ||||
|         /*   name,    appname,        summary,         body,  icon,  msg_urgency, timeout,  urgency,  fg,    bg,        format,  script */ | ||||
|         {    "empty", NULL,           NULL,            NULL,  NULL,  -1,          -1,       -1,       NULL,  NULL,      NULL,    NULL}, | ||||
|         /* { "rule1", "notify-send",  NULL,            NULL,  NULL,  -1,          -1,       -1,       NULL,  NULL,      "%s %b", NULL }, */ | ||||
|         /* { "rule2", "Pidgin",       "*says*,         NULL,  NULL,  -1,          -1,       CRITICAL, NULL,  NULL,      NULL,    NULL    }, */ | ||||
|         /* { "rule3", "Pidgin",       "*signed on*",   NULL,  NULL,  -1,          -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,       -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 | ||||
| # override settings for certain messages. | ||||
| # Messages can be matched by "appname", "summary", "body" or "icon" and | ||||
| # you can override the "timeout", "urgency", "foreground", "background" | ||||
| # and "format". | ||||
| # Messages can be matched by "appname", "summary", "body", "icon", | ||||
| # "msg_urgency" and you can override the "timeout", "urgency", "foreground", | ||||
| # "background" and "format". | ||||
| # Shell-like globbing will get expanded. | ||||
| # | ||||
| # SCRIPTING | ||||
|  | ||||
							
								
								
									
										4
									
								
								rules.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								rules.c
									
									
									
									
									
								
							| @ -48,6 +48,7 @@ void rule_init(rule_t * r) | ||||
|         r->summary = NULL; | ||||
|         r->body = NULL; | ||||
|         r->icon = NULL; | ||||
|         r->msg_urgency = -1; | ||||
|         r->timeout = -1; | ||||
|         r->urgency = -1; | ||||
|         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)) | ||||
|                 && (!r->summary || !fnmatch(r->summary, n->summary, 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: */ | ||||
|  | ||||
							
								
								
									
										1
									
								
								rules.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								rules.h
									
									
									
									
									
								
							| @ -13,6 +13,7 @@ typedef struct _rule_t { | ||||
|         char *summary; | ||||
|         char *body; | ||||
|         char *icon; | ||||
|         int msg_urgency; | ||||
| 
 | ||||
|         /* actions */ | ||||
|         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) | ||||
| { | ||||
| 
 | ||||
| @ -291,22 +312,8 @@ void load_settings(char *cmdline_config_path) | ||||
|                 r->body = ini_get_string(cur_section, "body", r->body); | ||||
|                 r->icon = ini_get_string(cur_section, "icon", r->icon); | ||||
|                 r->timeout = ini_get_int(cur_section, "timeout", r->timeout); | ||||
|                 { | ||||
|                         char *urg = ini_get_string(cur_section, "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->urgency = ini_get_urgency(cur_section, "urgency", r->urgency); | ||||
|                 r->msg_urgency = ini_get_urgency(cur_section, "msg_urgency", r->msg_urgency); | ||||
|                 r->fg = ini_get_string(cur_section, "foreground", r->fg); | ||||
|                 r->bg = ini_get_string(cur_section, "background", r->bg); | ||||
|                 r->format = ini_get_string(cur_section, "format", r->format); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Sascha Kruse
						Sascha Kruse