diff -u dmenu-4.4/dmenu.1 dmenu-quiet-4.4/dmenu.1 --- dmenu-4.4/dmenu.1 2011-07-19 22:31:28.000000000 +0200 +++ dmenu-quiet-4.4/dmenu.1 2011-08-05 19:39:31.000000000 +0200 @@ -41,6 +41,9 @@ .B \-b dmenu appears at the bottom of the screen. .TP +.B \-q +dmenu will not show any items if the search string is empty. +.TP .B \-f dmenu grabs the keyboard before reading stdin. This is faster, but may lock up X if stdin is from a terminal. diff -u dmenu-4.4/dmenu.c dmenu-quiet-4.4/dmenu.c --- dmenu-4.4/dmenu.c 2011-07-19 22:31:28.000000000 +0200 +++ dmenu-quiet-4.4/dmenu.c 2011-08-05 19:39:31.000000000 +0200 @@ -53,6 +53,7 @@ static unsigned long selcol[ColLast]; static Atom utf8; static Bool topbar = True; +static Bool quiet = False; static DC *dc; static Item *items = NULL; static Item *matches, *matchend; @@ -75,6 +76,8 @@ } else if(!strcmp(argv[i], "-b")) topbar = False; + else if(!strcmp(argv[i], "-q")) + quiet = True; else if(!strcmp(argv[i], "-f")) fast = True; else if(!strcmp(argv[i], "-i")) { @@ -177,28 +180,30 @@ if((curpos = textnw(dc, text, cursor) + dc->h/2 - 2) < dc->w) drawrect(dc, curpos, 2, 1, dc->h - 4, True, FG(dc, normcol)); - if(lines > 0) { - dc->w = mw - dc->x; - for(item = curr; item != next; item = item->right) { - dc->y += dc->h; - drawtext(dc, item->text, (item == sel) ? selcol : normcol); - } - } - else if(matches) { - dc->x += inputw; - dc->w = textw(dc, "<"); - if(curr->left) - drawtext(dc, "<", normcol); - for(item = curr; item != next; item = item->right) { - dc->x += dc->w; - dc->w = MIN(textw(dc, item->text), mw - dc->x - textw(dc, ">")); - drawtext(dc, item->text, (item == sel) ? selcol : normcol); - } - dc->w = textw(dc, ">"); - dc->x = mw - dc->w; - if(next) - drawtext(dc, ">", normcol); - } + if(!quiet || strlen(text) > 0) { + if(lines > 0) { + dc->w = mw - dc->x; + for(item = curr; item != next; item = item->right) { + dc->y += dc->h; + drawtext(dc, item->text, (item == sel) ? selcol : normcol); + } + } + else if(matches) { + dc->x += inputw; + dc->w = textw(dc, "<"); + if(curr->left) + drawtext(dc, "<", normcol); + for(item = curr; item != next; item = item->right) { + dc->x += dc->w; + dc->w = MIN(textw(dc, item->text), mw - dc->x - textw(dc, ">")); + drawtext(dc, item->text, (item == sel) ? selcol : normcol); + } + dc->w = textw(dc, ">"); + dc->x = mw - dc->w; + if(next) + drawtext(dc, ">", normcol); + } + } mapdc(dc, win, mw, mh); } @@ -532,7 +537,7 @@ void usage(void) { - fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn font]\n" + fputs("usage: dmenu [-b] [-q] [-f] [-i] [-l lines] [-p prompt] [-fn font]\n" " [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr); exit(EXIT_FAILURE); }