diff -r 56ee9af6dcea config.mk --- a/config.mk Sat Nov 19 21:31:18 2011 +0100 +++ b/config.mk Mon Nov 21 21:17:44 2011 +0100 @@ -17,7 +17,7 @@ LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} # flags -CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} +CPPFLAGS = -D_BSD_SOURCE -D_POSIX_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} CFLAGS = -ansi -pedantic -Wall -Os ${INCS} ${CPPFLAGS} LDFLAGS = -s ${LIBS} diff -r 56ee9af6dcea dmenu.c --- a/dmenu.c Sat Nov 19 21:31:18 2011 +0100 +++ b/dmenu.c Mon Nov 21 21:17:44 2011 +0100 @@ -55,6 +55,7 @@ static Atom clip, utf8; static Bool topbar = True; static DC *dc; +static FILE *incfp = NULL; static Item *items = NULL; static Item *matches, *matchend; static Item *prev, *curr, *next, *sel; @@ -90,6 +91,8 @@ lines = atoi(argv[++i]); else if(!strcmp(argv[i], "-p")) /* adds prompt to left of input field */ prompt = argv[++i]; + else if(!strcmp(argv[i], "-r")) /* incremental output on given descriptor */ + incfp = fdopen(atoi(argv[++i]), "w"); else if(!strcmp(argv[i], "-fn")) /* font or font set */ font = argv[++i]; else if(!strcmp(argv[i], "-nb")) /* normal background color */ @@ -388,6 +391,8 @@ size_t len; Item *item, *lprefix, *lsubstr, *prefixend, *substrend; + if(incfp) + fprintf(incfp, "%s\n", text); strcpy(buf, text); /* separate input text into tokens to be matched individually */ for(s = strtok(buf, " "); s; tokv[tokc-1] = s, s = strtok(NULL, " ")) @@ -594,7 +599,7 @@ void usage(void) { - fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn font]\n" + fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-r fd] [-fn font]\n" " [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr); exit(EXIT_FAILURE); }