diff -r 178b077493cf dmenu.1 --- a/dmenu.1 Fri Feb 10 00:37:42 2012 +0000 +++ b/dmenu.1 Tue Mar 06 21:56:00 2012 -0800 @@ -20,6 +20,8 @@ .IR color ] .RB [ \-sf .IR color ] +.RB [ \-w +.IR width ] .RB [ \-v ] .P .BR dmenu_run " ..." @@ -70,6 +72,9 @@ .BI \-sf " color" defines the selected foreground color. .TP +.BI \-w " width" +sets width of the menu in pixels +.TP .B \-v prints version information to stdout, then exits. .SH USAGE diff -r 178b077493cf dmenu.c --- a/dmenu.c Fri Feb 10 00:37:42 2012 +0000 +++ b/dmenu.c Tue Mar 06 21:56:00 2012 -0800 @@ -50,6 +50,7 @@ static const char *selbgcolor = "#005577"; static const char *selfgcolor = "#eeeeee"; static unsigned int lines = 0; +static unsigned int width = 0; static unsigned long normcol[ColLast]; static unsigned long selcol[ColLast]; static Atom clip, utf8; @@ -100,6 +101,8 @@ selbgcolor = argv[++i]; else if(!strcmp(argv[i], "-sf")) /* selected foreground color */ selfgcolor = argv[++i]; + else if(!strcmp(argv[i], "-w")) /* changes menu width */ + width = atoi(argv[++i]); else usage(); @@ -569,7 +572,7 @@ x = info[i].x_org; y = info[i].y_org + (topbar ? 0 : info[i].height - mh); - mw = info[i].width; + mw = width > 0 ? width : info[i].width; XFree(info); } else @@ -577,7 +580,7 @@ { x = 0; y = topbar ? 0 : DisplayHeight(dc->dpy, screen) - mh; - mw = DisplayWidth(dc->dpy, screen); + mw = width > 0 ? width : DisplayWidth(dc->dpy, screen); } promptw = prompt ? textw(dc, prompt) : 0; inputw = MIN(inputw, mw/3); @@ -605,6 +608,6 @@ void usage(void) { fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn font]\n" - " [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr); + " [-nb color] [-nf color] [-sb color] [-sf color] [-w width] [-v]\n", stderr); exit(EXIT_FAILURE); }