more timeout option
added individual timeouts for each urgency-level
This commit is contained in:
		
							parent
							
								
									8c48a33f31
								
							
						
					
					
						commit
						c3440b97ac
					
				
							
								
								
									
										32
									
								
								README
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								README
									
									
									
									
									
								
							| @ -1,4 +1,4 @@ | |||||||
| DNOTIFY(1)                                                                                                                                                                                  DNOTIFY(1) | DNOTIFY(1)                                                                                                                                                                             DNOTIFY(1) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -6,11 +6,12 @@ NAME | |||||||
|        dunst - dmenu-ish universal notification system |        dunst - dmenu-ish universal notification system | ||||||
| 
 | 
 | ||||||
| SYNOPSIS | SYNOPSIS | ||||||
|        dunst [-geometry geom] [-fn font] [-nf color] [-nb color] [-lf color] [-lb color] [-cf color] [-cb color] [-to secs] [-format fmt] [-key key] [-mod modifier] [-mon n] |        dunst  [-geometry  geom]  [-fn font] [-nf color] [-nb color] [-lf color] [-lb color] [-cf color] [-cb color] [-to secs] [-nto secs] [-lto secs] [-cto secs] [-format fmt] [-key key] [-mod | ||||||
|  |        modifier] [-mon n] | ||||||
| 
 | 
 | ||||||
| DESCRIPTION | DESCRIPTION | ||||||
|        dunst  is  a lightweight notification-daemon for the libnotify. It can also be used as a standalone notification system. Dnotify displays messages received via dbus or as commandline argument |        dunst is a lightweight notification-daemon for the libnotify. It can also be used as a standalone notification system. Dnotify displays messages received via dbus or as commandline argu‐ | ||||||
|        in a fashion similar to dmenu and additionally prints them to stdout. Notifications can be closed via mouseclick. |        ment in a fashion similar to dmenu and additionally prints them to stdout. Notifications can be closed via mouseclick. | ||||||
| 
 | 
 | ||||||
| OPTIONS | OPTIONS | ||||||
|        -h/--help |        -h/--help | ||||||
| @ -41,14 +42,23 @@ OPTIONS | |||||||
|               display msg instead of listening to notifications. This option can be used multiple times. |               display msg instead of listening to notifications. This option can be used multiple times. | ||||||
| 
 | 
 | ||||||
|        -to secs |        -to secs | ||||||
|               display each message for secs seconds. |               timeout for messages with low and normal urgency. Messages with a timeout of 0 will not dissappear automaticly (defaults to 10) | ||||||
|  | 
 | ||||||
|  |        -nto secs | ||||||
|  |               timeout for messages with normal urgency (defaults to 10) | ||||||
|  | 
 | ||||||
|  |        -lto secs | ||||||
|  |               timeout for messages with low urgency (defaults to 10) | ||||||
|  | 
 | ||||||
|  |        -cto secs | ||||||
|  |               timeout for messages with critical urgency (defaults to 0) | ||||||
| 
 | 
 | ||||||
|        -key key |        -key key | ||||||
|               close window by pressing key [a,b,space,Return etc.] (should be used in combination with -mod). |               close window by pressing key [a,b,space,Return etc.] (should be used in combination with -mod). | ||||||
| 
 | 
 | ||||||
|        -mod modifier |        -mod modifier | ||||||
|               defines the modifier for the key. Available modifiers are: ctrl,shift,mod1 (usually the alt-key),mod2,mod3,mod4 (usually windows key). This option can be used multiple times to combine |               defines  the  modifier  for the key. Available modifiers are: ctrl,shift,mod1 (usually the alt-key),mod2,mod3,mod4 (usually windows key). This option can be used multiple times to | ||||||
|               modifiers. |               combine modifiers. | ||||||
| 
 | 
 | ||||||
|        -format fmt |        -format fmt | ||||||
|               defines the format of the messages. See FORMAT. |               defines the format of the messages. See FORMAT. | ||||||
| @ -56,9 +66,9 @@ OPTIONS | |||||||
|        -mon n show the notification on monitor n. |        -mon n show the notification on monitor n. | ||||||
| 
 | 
 | ||||||
|        -geometry [[<width>]x<height>][+/-<X>+/-<y>] |        -geometry [[<width>]x<height>][+/-<X>+/-<y>] | ||||||
|               The  geometry  of  the  message  window. The height is measured in lines everything else in pixels. If the width is omitted but the height is given ("-geometry x2"), the message window |               The geometry of the message window. The height is measured in lines everything else in pixels. If the width is omitted but the height is given ("-geometry x2"), the message window | ||||||
|               expands over the whole screen (dmenu-like). If width is 0, the window expands to the longest message displayed. A positive x is measured from the left, a negative from the  right  side |               expands  over  the whole screen (dmenu-like). If width is 0, the window expands to the longest message displayed. A positive x is measured from the left, a negative from the right | ||||||
|               of the screen. Y is measured from the top and down respectevly. see also EXAMPLES show the notification on monitor n. |               side of the screen. Y is measured from the top and down respectevly. see also EXAMPLES show the notification on monitor n. | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| FORMAT | FORMAT | ||||||
| @ -101,4 +111,4 @@ SEE also | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|                                                                                                                                                                                             DNOTIFY(1) |                                                                                                                                                                                        DNOTIFY(1) | ||||||
|  | |||||||
							
								
								
									
										17
									
								
								dunst.1
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								dunst.1
									
									
									
									
									
								
							| @ -21,6 +21,12 @@ dunst \- dmenu\-ish universal notification system | |||||||
| .IR color ] | .IR color ] | ||||||
| .RB [ \-to | .RB [ \-to | ||||||
| .IR secs ] | .IR secs ] | ||||||
|  | .RB [ \-nto | ||||||
|  | .IR secs ] | ||||||
|  | .RB [ \-lto | ||||||
|  | .IR secs ] | ||||||
|  | .RB [ \-cto | ||||||
|  | .IR secs ] | ||||||
| .RB [ \-format | .RB [ \-format | ||||||
| .IR fmt ] | .IR fmt ] | ||||||
| .RB [ \-key | .RB [ \-key | ||||||
| @ -63,7 +69,16 @@ defines the forground color for critical messages. | |||||||
| display msg instead of listening to notifications. This option can be used multiple times. | display msg instead of listening to notifications. This option can be used multiple times. | ||||||
| .TP | .TP | ||||||
| .BI \-to " secs" | .BI \-to " secs" | ||||||
| display each message for secs seconds. | timeout for messages with low and normal urgency. Messages with a timeout of 0 will not dissappear automaticly (defaults to 10) | ||||||
|  | .TP | ||||||
|  | .BI \-nto " secs" | ||||||
|  | timeout for messages with normal urgency (defaults to 10) | ||||||
|  | .TP | ||||||
|  | .BI \-lto " secs" | ||||||
|  | timeout for messages with low urgency (defaults to 10) | ||||||
|  | .TP | ||||||
|  | .BI \-cto " secs" | ||||||
|  | timeout for messages with critical urgency (defaults to 0) | ||||||
| .TP | .TP | ||||||
| .BI \-key " key" | .BI \-key " key" | ||||||
| close window by pressing key [a,b,space,Return etc.] (should be used in combination with -mod). | close window by pressing key [a,b,space,Return etc.] (should be used in combination with -mod). | ||||||
|  | |||||||
							
								
								
									
										23
									
								
								dunst.c
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								dunst.c
									
									
									
									
									
								
							| @ -56,7 +56,7 @@ static unsigned long lowcol[ColLast]; | |||||||
| static Atom utf8; | static Atom utf8; | ||||||
| static DC *dc; | static DC *dc; | ||||||
| static Window win; | static Window win; | ||||||
| static double global_timeout = 10; | static double timeouts[] = { 10, 10, 0 }; | ||||||
| static msg_queue_t *msgqueue = NULL; | static msg_queue_t *msgqueue = NULL; | ||||||
| static time_t now; | static time_t now; | ||||||
| static int listen_to_dbus = True; | static int listen_to_dbus = True; | ||||||
| @ -96,11 +96,14 @@ append(msg_queue_t *queue, char *msg, int to, int urgency) { | |||||||
|     msg_queue_t *last; |     msg_queue_t *last; | ||||||
|     new->msg = xml_unescape(msg); |     new->msg = xml_unescape(msg); | ||||||
|     new->urgency = urgency; |     new->urgency = urgency; | ||||||
|  | 
 | ||||||
|     if(to == -1) { |     if(to == -1) { | ||||||
|         new->timeout = global_timeout; |         new->urgency = new->urgency > 2 ? 2 : new->urgency; | ||||||
|  |         new->timeout = timeouts[urgency]; | ||||||
|     } else { |     } else { | ||||||
|         new->timeout = to; |         new->timeout = to; | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|     new->start = 0; |     new->start = 0; | ||||||
|     printf("%s (timeout: %d, urgency: %d)\n", new->msg, new->timeout, urgency); |     printf("%s (timeout: %d, urgency: %d)\n", new->msg, new->timeout, urgency); | ||||||
|     new->next = NULL; |     new->next = NULL; | ||||||
| @ -201,7 +204,7 @@ delete_msg(msg_queue_t *elem) { | |||||||
|         /* delete the oldest element */ |         /* delete the oldest element */ | ||||||
|         tmp = msgqueue; |         tmp = msgqueue; | ||||||
|         for(elem = msgqueue; elem->next != NULL; elem = elem->next) { |         for(elem = msgqueue; elem->next != NULL; elem = elem->next) { | ||||||
|             if(tmp->start > 0 && tmp->start < elem->start) { |             if(tmp->start > 0 && tmp->start > elem->start) { | ||||||
|                 tmp = elem; |                 tmp = elem; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| @ -572,8 +575,16 @@ main(int argc, char *argv[]) { | |||||||
|             critbgcolor = argv[++i]; |             critbgcolor = argv[++i]; | ||||||
|         else if(!strcmp(argv[i], "-cf")) |         else if(!strcmp(argv[i], "-cf")) | ||||||
|             critfgcolor = argv[++i]; |             critfgcolor = argv[++i]; | ||||||
|         else if(!strcmp(argv[i], "-to")) |         else if(!strcmp(argv[i], "-to")) { | ||||||
|             global_timeout = atoi(argv[++i]); |             timeouts[0] = atoi(argv[++i]); | ||||||
|  |             timeouts[1] = timeouts[0]; | ||||||
|  |         } | ||||||
|  |         else if(!strcmp(argv[i], "-lto")) | ||||||
|  |             timeouts[0] = atoi(argv[++i]); | ||||||
|  |         else if(!strcmp(argv[i], "-nto")) | ||||||
|  |             timeouts[1] = atoi(argv[++i]); | ||||||
|  |         else if(!strcmp(argv[i], "-cto")) | ||||||
|  |             timeouts[2] = atoi(argv[++i]); | ||||||
|         else if(!strcmp(argv[i], "-msg")) { |         else if(!strcmp(argv[i], "-msg")) { | ||||||
|              msgqueue = append(msgqueue, strdup(argv[++i]), -1, 1); |              msgqueue = append(msgqueue, strdup(argv[++i]), -1, 1); | ||||||
|              listen_to_dbus = False; |              listen_to_dbus = False; | ||||||
| @ -638,6 +649,6 @@ main(int argc, char *argv[]) { | |||||||
| 
 | 
 | ||||||
| void | void | ||||||
| usage(int exit_status) { | usage(int exit_status) { | ||||||
|     fputs("usage: dunst [-h/--help] [-geometry geom] [-fn font] [-format fmt]\n[-nb color] [-nf color] [-lb color] [-lf color] [-cb color] [ -cf color]\n[-to secs] [-key key] [-mod modifier] [-mon n] [-msg msg]\n", stderr); |     fputs("usage: dunst [-h/--help] [-geometry geom] [-fn font] [-format fmt]\n[-nb color] [-nf color] [-lb color] [-lf color] [-cb color] [ -cf color]\n[-to secs] [-lto secs] [-cto secs] [-nto secs] [-key key] [-mod modifier] [-mon n] [-msg msg]\n", stderr); | ||||||
|     exit(exit_status); |     exit(exit_status); | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Sascha Kruse
						Sascha Kruse