X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=dmenu.c;h=2193f8229b3eed41eccf3fa041ebbed6803658f9;hb=e0e6b071c63f960c398b43b2fbf0dec66a9b3ab6;hp=d8ef88f132866a4c3c7f67a7670218abe15aa9ce;hpb=210b303941e517a9d7df1cba1e3229165fb4037b;p=dmenu.git diff --git a/dmenu.c b/dmenu.c index d8ef88f..2193f82 100644 --- a/dmenu.c +++ b/dmenu.c @@ -64,6 +64,7 @@ static int (*fstrncmp)(const char *, const char *, size_t) = strncmp; int main(int argc, char *argv[]) { + Bool fast = False; int i; progname = "dmenu"; @@ -77,6 +78,8 @@ main(int argc, char *argv[]) { topbar = False; else if(!strcmp(argv[i], "-i")) fstrncmp = strncasecmp; + else if(!strcmp(argv[i], "-f")) + fast = True; else if(i == argc-1) goto usage; /* double flags */ @@ -101,13 +104,21 @@ main(int argc, char *argv[]) { dc = initdc(); initfont(dc, font); - readstdin(); - setup(); + + if(fast) { + setup(); + readstdin(); + } + else { + readstdin(); + setup(); + } + match(); run(); return EXIT_FAILURE; usage: - fputs("usage: dmenu [-b] [-i] [-l lines] [-m monitor] [-p prompt] [-fn font]\n" + fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-m monitor] [-p prompt] [-fn font]\n" " [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr); return EXIT_FAILURE; } @@ -440,9 +451,9 @@ readstdin(void) { if((p = strchr(buf, '\n'))) *p = '\0'; if(!(item = calloc(1, sizeof *item))) - eprintf("cannot malloc %u bytes\n", sizeof *item); + eprintf("cannot malloc %u bytes:", sizeof *item); if(!(item->text = strdup(buf))) - eprintf("cannot strdup %u bytes\n", strlen(buf)+1); + eprintf("cannot strdup %u bytes:", strlen(buf)+1); inputw = MAX(inputw, textw(dc, item->text)); } } @@ -530,5 +541,4 @@ setup(void) { inputw = MIN(inputw, mw/3); promptw = prompt ? textw(dc, prompt) : 0; XMapRaised(dc->dpy, win); - match(); }