verbose-mode and output cleanup
This commit is contained in:
parent
41401d0985
commit
f4508c1dbe
22
README
22
README
@ -1,4 +1,4 @@
|
||||
DNOTIFY(1) DNOTIFY(1)
|
||||
DNOTIFY(1) DNOTIFY(1)
|
||||
|
||||
|
||||
|
||||
@ -6,12 +6,11 @@ NAME
|
||||
dunst - dmenu-ish universal notification system
|
||||
|
||||
SYNOPSIS
|
||||
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]
|
||||
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] [-v]
|
||||
|
||||
DESCRIPTION
|
||||
dunst is a lightweight notification-daemon for the libnotify. Dnotify displays messages received via dbus or as commandline argument in a fashion similar to dmenu and additionally prints
|
||||
them to stdout. Notifications can be closed via mouseclick.
|
||||
dunst is a lightweight notification-daemon for the libnotify. Dnotify displays messages received via dbus or as commandline argument in a fashion similar to dmenu and additionally prints them to stdout. Notifications
|
||||
can be closed via mouseclick.
|
||||
|
||||
OPTIONS
|
||||
-h/--help
|
||||
@ -54,8 +53,7 @@ OPTIONS
|
||||
close window by pressing key [a,b,space,Return etc.] (should be used in combination with -mod).
|
||||
|
||||
-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 modifiers.
|
||||
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 modifiers.
|
||||
|
||||
-format fmt
|
||||
defines the format of the messages. See FORMAT.
|
||||
@ -63,9 +61,11 @@ OPTIONS
|
||||
-mon n show the notification on monitor n.
|
||||
|
||||
-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
|
||||
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 of the screen. Y is measured from the top and down respectevly. see also EXAMPLES show the notification on monitor n.
|
||||
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 of the screen. Y is measured from the top and down
|
||||
respectevly. see also EXAMPLES show the notification on monitor n.
|
||||
|
||||
-v Activate verbose mode.
|
||||
|
||||
|
||||
NOTIFY-SEND
|
||||
@ -117,4 +117,4 @@ SEE also
|
||||
|
||||
|
||||
|
||||
DNOTIFY(1)
|
||||
DNOTIFY(1)
|
||||
|
4
dunst.1
4
dunst.1
@ -35,6 +35,7 @@ dunst \- dmenu\-ish universal notification system
|
||||
.IR modifier ]
|
||||
.RB [ \-mon
|
||||
.IR n ]
|
||||
.RB [ \-v ]
|
||||
.P
|
||||
.SH DESCRIPTION
|
||||
.B dunst
|
||||
@ -92,6 +93,9 @@ show the notification on monitor n.
|
||||
.BI \-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 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 of the screen. Y is measured from the top and down respectevly. see also EXAMPLES
|
||||
show the notification on monitor n.
|
||||
.TP
|
||||
.BI \-v
|
||||
Activate verbose mode.
|
||||
|
||||
.SH NOTIFY-SEND
|
||||
dunst is able to get different colors for a message via notify-send. For that, you have to add a hint via the -h option.
|
||||
|
25
dunst.c
25
dunst.c
@ -69,6 +69,7 @@ static screen_info scr;
|
||||
static dimension_t geometry;
|
||||
static int font_h;
|
||||
static const char *format = "%s %b";
|
||||
static int verbose = False;
|
||||
|
||||
/* list functions */
|
||||
msg_queue_t *append(msg_queue_t *queue, char *msg, int to, int urgency, const char *fg, const char *bg);
|
||||
@ -81,6 +82,7 @@ int list_len(msg_queue_t *list);
|
||||
void check_timeouts(void);
|
||||
void delete_msg(msg_queue_t *elem);
|
||||
void drawmsg(void);
|
||||
void dunst_printf(const char *fmt, ...);
|
||||
char *fix_markup(char *str);
|
||||
char *format_msg(const char *app, const char *sum, const char *body, const char *icon);
|
||||
void handleXEvents(void);
|
||||
@ -122,7 +124,7 @@ append(msg_queue_t *queue, char *msg, int to, int urgency, const char *fg, const
|
||||
}
|
||||
|
||||
new->start = 0;
|
||||
printf("%s (timeout: %d, urgency: %d)\n", new->msg, new->timeout, urgency);
|
||||
dunst_printf("%s (timeout: %d, urgency: %d)\n", new->msg, new->timeout, urgency);
|
||||
new->next = NULL;
|
||||
if(queue == NULL) {
|
||||
return new;
|
||||
@ -318,6 +320,18 @@ drawmsg(void) {
|
||||
mapdc(dc, win, width, height*font_h);
|
||||
}
|
||||
|
||||
void
|
||||
dunst_printf(const char *fmt, ...) {
|
||||
va_list ap;
|
||||
|
||||
if(!verbose) {
|
||||
return;
|
||||
}
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
char
|
||||
*fix_markup(char *str) {
|
||||
char *tmpString, *strpos, *tmppos;
|
||||
@ -390,7 +404,6 @@ char
|
||||
end = strstr(tmpString, ">");
|
||||
if(end != NULL) {
|
||||
replace_buf = strndup(start, end-start+1);
|
||||
printf("replace_buf: '%s'\n", replace_buf);
|
||||
tmpString = string_replace(replace_buf, "", tmpString);
|
||||
free(replace_buf);
|
||||
}
|
||||
@ -400,7 +413,6 @@ char
|
||||
end = strstr(tmpString, "/>");
|
||||
if(end != NULL) {
|
||||
replace_buf = strndup(start, end-start+2);
|
||||
printf("replace_buf: '%s'\n", replace_buf);
|
||||
tmpString = string_replace(replace_buf, "", tmpString);
|
||||
free(replace_buf);
|
||||
}
|
||||
@ -590,12 +602,15 @@ main(int argc, char *argv[]) {
|
||||
if(!strcmp(argv[i], "-b")) {
|
||||
geometry.mask |= YNegative;
|
||||
}
|
||||
if(!strcmp(argv[i], "-v")) {
|
||||
verbose = True;
|
||||
}
|
||||
else if(!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help"))
|
||||
usage(EXIT_SUCCESS);
|
||||
|
||||
/* options */
|
||||
else if(i == argc-1) {
|
||||
printf("Option needs an argument\n");
|
||||
fprintf(stderr, "Option needs an argument\n");
|
||||
usage(1);
|
||||
}
|
||||
else if(!strcmp(argv[i], "-fn"))
|
||||
@ -679,6 +694,6 @@ main(int argc, char *argv[]) {
|
||||
|
||||
void
|
||||
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] [-lto secs] [-cto secs] [-nto secs] [-key key] [-mod modifier] [-mon n]\n", stderr);
|
||||
fputs("usage: dunst [-h/--help] [-q] [-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]\n", stderr);
|
||||
exit(exit_status);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user