https://bbs.archlinux.org/viewtopic.php?id=124915
diff -u dmenu-4.4/dmenu.1 dmenu/dmenu.1 --- dmenu-4.4/dmenu.1 2011-07-19 22:31:28.000000000 +0200 +++ dmenu/dmenu.1 2011-08-06 23:18:20.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. @@ -57,6 +60,15 @@ .BI \-fn " font" defines the font or font set used. .TP +.BI \-x " xoffset" +defines the offset from the left border of the screen. +.TP +.BI \-y " yoffset" +defines the offset from the top border of the screen. +.TP +.BI \-w " width" +defines the desired menu window width. +.TP .BI \-nb " color" defines the normal background color. .IR #RGB , diff -u dmenu-4.4/dmenu.c dmenu/dmenu.c --- dmenu-4.4/dmenu.c 2011-07-19 22:31:28.000000000 +0200 +++ dmenu/dmenu.c 2011-08-06 23:17:53.000000000 +0200 @@ -42,6 +42,9 @@ static int bh, mw, mh; static int inputw, promptw; static int lines = 0; +static int xoffset = 0; +static int yoffset = 0; +static int width = 0; static size_t cursor = 0; static const char *font = NULL; static const char *prompt = NULL; @@ -53,6 +56,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 +79,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")) { @@ -84,6 +90,12 @@ else if(i+1 == argc) usage(); /* double flags */ + else if(!strcmp(argv[i], "-x")) + xoffset = atoi(argv[++i]); + else if(!strcmp(argv[i], "-y")) + yoffset = atoi(argv[++i]); + else if(!strcmp(argv[i], "-w")) + width = atoi(argv[++i]); else if(!strcmp(argv[i], "-l")) lines = atoi(argv[++i]); else if(!strcmp(argv[i], "-p")) @@ -177,28 +189,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); } @@ -501,7 +515,7 @@ if(INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height)) break; x = info[i].x_org; - y = info[i].y_org + (topbar ? 0 : info[i].height - mh); + y = info[i].y_org + (topbar ? yoffset : info[i].height - mh - yoffset); mw = info[i].width; XFree(info); } @@ -509,9 +523,13 @@ #endif { x = 0; - y = topbar ? 0 : DisplayHeight(dc->dpy, screen) - mh; + y = topbar ? yoffset : DisplayHeight(dc->dpy, screen) - mh - yoffset; mw = DisplayWidth(dc->dpy, screen); } + + x += xoffset; + mw = width ? width : mw; + promptw = prompt ? textw(dc, prompt) : 0; inputw = MIN(inputw, mw/3); match(False); @@ -532,7 +550,8 @@ 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" + " [-x xoffset] [-y yoffset] [-w width]\n" " [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr); exit(EXIT_FAILURE); }