summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--patches/1.dmenu-xresources-4.9.diff126
-rw-r--r--patches/2.dmenu-password-5.0.diff103
-rw-r--r--patches/3.dmenu-highpriority-5.1.diff174
-rw-r--r--patches/4.dmenu-mousesupport-5.2.diff144
-rw-r--r--patches/5.dmenu-lineheight-5.0.diff106
5 files changed, 653 insertions, 0 deletions
diff --git a/patches/1.dmenu-xresources-4.9.diff b/patches/1.dmenu-xresources-4.9.diff
new file mode 100644
index 0000000..267fb0a
--- /dev/null
+++ b/patches/1.dmenu-xresources-4.9.diff
@@ -0,0 +1,126 @@
+diff '--color=auto' -up ../dmenu-4.9/dmenu.c ./dmenu.c
+--- ../dmenu-4.9/dmenu.c 2019-02-02 13:55:02.000000000 +0100
++++ ./dmenu.c 2020-05-24 00:27:58.038586112 +0200
+@@ -15,6 +15,7 @@
+ #include <X11/extensions/Xinerama.h>
+ #endif
+ #include <X11/Xft/Xft.h>
++#include <X11/Xresource.h>
+
+ #include "drw.h"
+ #include "util.h"
+@@ -53,6 +54,10 @@ static XIC xic;
+ static Drw *drw;
+ static Clr *scheme[SchemeLast];
+
++/* Temporary arrays to allow overriding xresources values */
++static char *colortemp[4];
++static char *tempfonts;
++
+ #include "config.h"
+
+ static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
+@@ -596,8 +601,13 @@ setup(void)
+ int a, di, n, area = 0;
+ #endif
+ /* init appearance */
+- for (j = 0; j < SchemeLast; j++)
+- scheme[j] = drw_scm_create(drw, colors[j], 2);
++ for (j = 0; j < SchemeLast; j++) {
++ scheme[j] = drw_scm_create(drw, (const char**)colors[j], 2);
++ }
++ for (j = 0; j < SchemeOut; ++j) {
++ for (i = 0; i < 2; ++i)
++ free(colors[j][i]);
++ }
+
+ clip = XInternAtom(dpy, "CLIPBOARD", False);
+ utf8 = XInternAtom(dpy, "UTF8_STRING", False);
+@@ -687,6 +697,41 @@ usage(void)
+ exit(1);
+ }
+
++void
++readxresources(void) {
++ XrmInitialize();
++
++ char* xrm;
++ if ((xrm = XResourceManagerString(drw->dpy))) {
++ char *type;
++ XrmDatabase xdb = XrmGetStringDatabase(xrm);
++ XrmValue xval;
++
++ if (XrmGetResource(xdb, "dmenu.font", "*", &type, &xval))
++ fonts[0] = strdup(xval.addr);
++ else
++ fonts[0] = strdup(fonts[0]);
++ if (XrmGetResource(xdb, "dmenu.background", "*", &type, &xval))
++ colors[SchemeNorm][ColBg] = strdup(xval.addr);
++ else
++ colors[SchemeNorm][ColBg] = strdup(colors[SchemeNorm][ColBg]);
++ if (XrmGetResource(xdb, "dmenu.foreground", "*", &type, &xval))
++ colors[SchemeNorm][ColFg] = strdup(xval.addr);
++ else
++ colors[SchemeNorm][ColFg] = strdup(colors[SchemeNorm][ColFg]);
++ if (XrmGetResource(xdb, "dmenu.selbackground", "*", &type, &xval))
++ colors[SchemeSel][ColBg] = strdup(xval.addr);
++ else
++ colors[SchemeSel][ColBg] = strdup(colors[SchemeSel][ColBg]);
++ if (XrmGetResource(xdb, "dmenu.selforeground", "*", &type, &xval))
++ colors[SchemeSel][ColFg] = strdup(xval.addr);
++ else
++ colors[SchemeSel][ColFg] = strdup(colors[SchemeSel][ColFg]);
++
++ XrmDestroyDatabase(xdb);
++ }
++}
++
+ int
+ main(int argc, char *argv[])
+ {
+@@ -715,15 +760,15 @@ main(int argc, char *argv[])
+ else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
+ prompt = argv[++i];
+ else if (!strcmp(argv[i], "-fn")) /* font or font set */
+- fonts[0] = argv[++i];
++ tempfonts = argv[++i];
+ else if (!strcmp(argv[i], "-nb")) /* normal background color */
+- colors[SchemeNorm][ColBg] = argv[++i];
++ colortemp[0] = argv[++i];
+ else if (!strcmp(argv[i], "-nf")) /* normal foreground color */
+- colors[SchemeNorm][ColFg] = argv[++i];
++ colortemp[1] = argv[++i];
+ else if (!strcmp(argv[i], "-sb")) /* selected background color */
+- colors[SchemeSel][ColBg] = argv[++i];
++ colortemp[2] = argv[++i];
+ else if (!strcmp(argv[i], "-sf")) /* selected foreground color */
+- colors[SchemeSel][ColFg] = argv[++i];
++ colortemp[3] = argv[++i];
+ else if (!strcmp(argv[i], "-w")) /* embedding window id */
+ embed = argv[++i];
+ else
+@@ -743,8 +788,23 @@ main(int argc, char *argv[])
+ die("could not get embedding window attributes: 0x%lx",
+ parentwin);
+ drw = drw_create(dpy, screen, root, wa.width, wa.height);
+- if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
++ readxresources();
++ /* Now we check whether to override xresources with commandline parameters */
++ if ( tempfonts )
++ fonts[0] = strdup(tempfonts);
++ if ( colortemp[0])
++ colors[SchemeNorm][ColBg] = strdup(colortemp[0]);
++ if ( colortemp[1])
++ colors[SchemeNorm][ColFg] = strdup(colortemp[1]);
++ if ( colortemp[2])
++ colors[SchemeSel][ColBg] = strdup(colortemp[2]);
++ if ( colortemp[3])
++ colors[SchemeSel][ColFg] = strdup(colortemp[3]);
++
++ if (!drw_fontset_create(drw, (const char**)fonts, LENGTH(fonts)))
+ die("no fonts could be loaded.");
++
++ free(fonts[0]);
+ lrpad = drw->fonts->h;
+
+ #ifdef __OpenBSD__
diff --git a/patches/2.dmenu-password-5.0.diff b/patches/2.dmenu-password-5.0.diff
new file mode 100644
index 0000000..7a187b9
--- /dev/null
+++ b/patches/2.dmenu-password-5.0.diff
@@ -0,0 +1,103 @@
+From c4de1032bd4c247bc20b6ab92a10a8d778966679 Mon Sep 17 00:00:00 2001
+From: Mehrad Mahmoudian <m.mahmoudian@gmail.com>
+Date: Tue, 4 May 2021 12:05:09 +0300
+Subject: [PATCH] patched with password patch
+
+---
+ dmenu.1 | 5 ++++-
+ dmenu.c | 21 +++++++++++++++++----
+ 2 files changed, 21 insertions(+), 5 deletions(-)
+
+diff --git a/dmenu.1 b/dmenu.1
+index 323f93c..762f707 100644
+--- a/dmenu.1
++++ b/dmenu.1
+@@ -3,7 +3,7 @@
+ dmenu \- dynamic menu
+ .SH SYNOPSIS
+ .B dmenu
+-.RB [ \-bfiv ]
++.RB [ \-bfivP ]
+ .RB [ \-l
+ .IR lines ]
+ .RB [ \-m
+@@ -47,6 +47,9 @@ is faster, but will lock up X until stdin reaches end\-of\-file.
+ .B \-i
+ dmenu matches menu items case insensitively.
+ .TP
++.B \-P
++dmenu will not directly display the keyboard input, but instead replace it with dots. All data from stdin will be ignored.
++.TP
+ .BI \-l " lines"
+ dmenu lists items vertically, with the given number of lines.
+ .TP
+diff --git a/dmenu.c b/dmenu.c
+index 65f25ce..ad8f63b 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -37,7 +37,7 @@ struct item {
+ static char text[BUFSIZ] = "";
+ static char *embed;
+ static int bh, mw, mh;
+-static int inputw = 0, promptw;
++static int inputw = 0, promptw, passwd = 0;
+ static int lrpad; /* sum of left and right padding */
+ static size_t cursor;
+ static struct item *items = NULL;
+@@ -132,6 +132,7 @@ drawmenu(void)
+ unsigned int curpos;
+ struct item *item;
+ int x = 0, y = 0, w;
++ char *censort;
+
+ drw_setscheme(drw, scheme[SchemeNorm]);
+ drw_rect(drw, 0, 0, mw, mh, 1, 1);
+@@ -143,7 +144,12 @@ drawmenu(void)
+ /* draw input field */
+ w = (lines > 0 || !matches) ? mw - x : inputw;
+ drw_setscheme(drw, scheme[SchemeNorm]);
+- drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
++ if (passwd) {
++ censort = ecalloc(1, sizeof(text));
++ memset(censort, '.', strlen(text));
++ drw_text(drw, x, 0, w, bh, lrpad / 2, censort, 0);
++ free(censort);
++ } else drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
+
+ curpos = TEXTW(text) - TEXTW(&text[cursor]);
+ if ((curpos += lrpad / 2 - 1) < w) {
+@@ -524,6 +530,11 @@ readstdin(void)
+ char buf[sizeof text], *p;
+ size_t i, imax = 0, size = 0;
+ unsigned int tmpmax = 0;
++ if(passwd){
++ inputw = lines = 0;
++ return;
++ }
++
+
+ /* read each line from stdin and add it to the item list */
+ for (i = 0; fgets(buf, sizeof buf, stdin); i++) {
+@@ -689,7 +700,7 @@ setup(void)
+ static void
+ usage(void)
+ {
+- fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
++ fputs("usage: dmenu [-bfivP] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
+ " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr);
+ exit(1);
+ }
+@@ -712,7 +723,9 @@ main(int argc, char *argv[])
+ else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
+ fstrncmp = strncasecmp;
+ fstrstr = cistrstr;
+- } else if (i + 1 == argc)
++ } else if (!strcmp(argv[i], "-P")) /* is the input a password */
++ passwd = 1;
++ else if (i + 1 == argc)
+ usage();
+ /* these options take one argument */
+ else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
+--
+2.31.1
+
diff --git a/patches/3.dmenu-highpriority-5.1.diff b/patches/3.dmenu-highpriority-5.1.diff
new file mode 100644
index 0000000..224ac0d
--- /dev/null
+++ b/patches/3.dmenu-highpriority-5.1.diff
@@ -0,0 +1,174 @@
+diff --git a/config.def.h b/config.def.h
+index 1edb647..47b616d 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -12,6 +12,7 @@ static const char *colors[SchemeLast][2] = {
+ [SchemeNorm] = { "#bbbbbb", "#222222" },
+ [SchemeSel] = { "#eeeeee", "#005577" },
+ [SchemeOut] = { "#000000", "#00ffff" },
++ [SchemeHp] = { "#bbbbbb", "#333333" }
+ };
+ /* -l option; if nonzero, dmenu uses vertical list with given number of lines */
+ static unsigned int lines = 0;
+diff --git a/dmenu.c b/dmenu.c
+index eca67ac..6ae896a 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -26,14 +26,16 @@
+ #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
+
+ /* enums */
+-enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
++enum { SchemeNorm, SchemeSel, SchemeHp, SchemeOut, SchemeLast }; /* color schemes */
+
+ struct item {
+ char *text;
+ struct item *left, *right;
+- int out;
++ int out, hp;
+ };
+
++static char **hpitems = NULL;
++static int hplength = 0;
+ static char text[BUFSIZ] = "";
+ static char *embed;
+ static int bh, mw, mh;
+@@ -58,6 +60,42 @@ static Clr *scheme[SchemeLast];
+ static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
+ static char *(*fstrstr)(const char *, const char *) = strstr;
+
++static char **
++tokenize(char *source, const char *delim, int *llen)
++{
++ int listlength = 0, list_size = 0;
++ char **list = NULL, *token;
++
++ token = strtok(source, delim);
++ while (token) {
++ if (listlength + 1 >= list_size) {
++ if (!(list = realloc(list, (list_size += 8) * sizeof(*list))))
++ die("Unable to realloc %zu bytes\n", list_size * sizeof(*list));
++ }
++ if (!(list[listlength] = strdup(token)))
++ die("Unable to strdup %zu bytes\n", strlen(token) + 1);
++ token = strtok(NULL, delim);
++ listlength++;
++ }
++
++ *llen = listlength;
++ return list;
++}
++
++static int
++arrayhas(char **list, int length, char *item)
++{
++ int i;
++
++ for (i = 0; i < length; i++) {
++ size_t len1 = strlen(list[i]);
++ size_t len2 = strlen(item);
++ if (!fstrncmp(list[i], item, len1 > len2 ? len2 : len1))
++ return 1;
++ }
++ return 0;
++}
++
+ static void
+ appenditem(struct item *item, struct item **list, struct item **last)
+ {
+@@ -97,6 +135,9 @@ cleanup(void)
+ XUngrabKey(dpy, AnyKey, AnyModifier, root);
+ for (i = 0; i < SchemeLast; i++)
+ free(scheme[i]);
++ for (i = 0; i < hplength; ++i)
++ free(hpitems[i]);
++ free(hpitems);
+ drw_free(drw);
+ XSync(dpy, False);
+ XCloseDisplay(dpy);
+@@ -125,6 +166,8 @@ drawitem(struct item *item, int x, int y, int w)
+ {
+ if (item == sel)
+ drw_setscheme(drw, scheme[SchemeSel]);
++ else if (item->hp)
++ drw_setscheme(drw, scheme[SchemeHp]);
+ else if (item->out)
+ drw_setscheme(drw, scheme[SchemeOut]);
+ else
+@@ -226,7 +269,7 @@ match(void)
+ char buf[sizeof text], *s;
+ int i, tokc = 0;
+ size_t len, textsize;
+- struct item *item, *lprefix, *lsubstr, *prefixend, *substrend;
++ struct item *item, *lhpprefix, *lprefix, *lsubstr, *hpprefixend, *prefixend, *substrend;
+
+ strcpy(buf, text);
+ /* separate input text into tokens to be matched individually */
+@@ -235,7 +278,7 @@ match(void)
+ die("cannot realloc %u bytes:", tokn * sizeof *tokv);
+ len = tokc ? strlen(tokv[0]) : 0;
+
+- matches = lprefix = lsubstr = matchend = prefixend = substrend = NULL;
++ matches = lhpprefix = lprefix = lsubstr = matchend = hpprefixend = prefixend = substrend = NULL;
+ textsize = strlen(text) + 1;
+ for (item = items; item && item->text; item++) {
+ for (i = 0; i < tokc; i++)
+@@ -243,14 +286,24 @@ match(void)
+ break;
+ if (i != tokc) /* not all tokens match */
+ continue;
+- /* exact matches go first, then prefixes, then substrings */
++ /* exact matches go first, then prefixes with high priority, then prefixes, then substrings */
+ if (!tokc || !fstrncmp(text, item->text, textsize))
+ appenditem(item, &matches, &matchend);
++ else if (item->hp && !fstrncmp(tokv[0], item->text, len))
++ appenditem(item, &lhpprefix, &hpprefixend);
+ else if (!fstrncmp(tokv[0], item->text, len))
+ appenditem(item, &lprefix, &prefixend);
+ else
+ appenditem(item, &lsubstr, &substrend);
+ }
++ if (lhpprefix) {
++ if (matches) {
++ matchend->right = lhpprefix;
++ lhpprefix->left = matchend;
++ } else
++ matches = lhpprefix;
++ matchend = hpprefixend;
++ }
+ if (lprefix) {
+ if (matches) {
+ matchend->right = lprefix;
+@@ -553,6 +606,7 @@ readstdin(void)
+ if (!(items[i].text = strdup(buf)))
+ die("cannot strdup %u bytes:", strlen(buf) + 1);
+ items[i].out = 0;
++ items[i].hp = arrayhas(hpitems, hplength, items[i].text);
+ drw_font_getexts(drw->fonts, buf, strlen(buf), &tmpmax, NULL);
+ if (tmpmax > inputw) {
+ inputw = tmpmax;
+@@ -708,7 +762,8 @@ static void
+ usage(void)
+ {
+ fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
+- " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr);
++ " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n"
++ " [-hb color] [-hf color] [-hp items]\n", stderr);
+ exit(1);
+ }
+
+@@ -749,8 +804,14 @@ main(int argc, char *argv[])
+ colors[SchemeSel][ColBg] = argv[++i];
+ else if (!strcmp(argv[i], "-sf")) /* selected foreground color */
+ colors[SchemeSel][ColFg] = argv[++i];
++ else if (!strcmp(argv[i], "-hb")) /* high priority background color */
++ colors[SchemeHp][ColBg] = argv[++i];
++ else if (!strcmp(argv[i], "-hf")) /* low priority background color */
++ colors[SchemeHp][ColFg] = argv[++i];
+ else if (!strcmp(argv[i], "-w")) /* embedding window id */
+ embed = argv[++i];
++ else if (!strcmp(argv[i], "-hp"))
++ hpitems = tokenize(argv[++i], ",", &hplength);
+ else
+ usage();
+
diff --git a/patches/4.dmenu-mousesupport-5.2.diff b/patches/4.dmenu-mousesupport-5.2.diff
new file mode 100644
index 0000000..eaacea4
--- /dev/null
+++ b/patches/4.dmenu-mousesupport-5.2.diff
@@ -0,0 +1,144 @@
+diff --git a/dmenu.c b/dmenu.c
+index 7cf253b..d276a94 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -528,6 +528,119 @@ draw:
+ drawmenu();
+ }
+
++static void
++buttonpress(XEvent *e)
++{
++ struct item *item;
++ XButtonPressedEvent *ev = &e->xbutton;
++ int x = 0, y = 0, h = bh, w;
++
++ if (ev->window != win)
++ return;
++
++ /* right-click: exit */
++ if (ev->button == Button3)
++ exit(1);
++
++ if (prompt && *prompt)
++ x += promptw;
++
++ /* input field */
++ w = (lines > 0 || !matches) ? mw - x : inputw;
++
++ /* left-click on input: clear input,
++ * NOTE: if there is no left-arrow the space for < is reserved so
++ * add that to the input width */
++ if (ev->button == Button1 &&
++ ((lines <= 0 && ev->x >= 0 && ev->x <= x + w +
++ ((!prev || !curr->left) ? TEXTW("<") : 0)) ||
++ (lines > 0 && ev->y >= y && ev->y <= y + h))) {
++ insert(NULL, -cursor);
++ drawmenu();
++ return;
++ }
++ /* middle-mouse click: paste selection */
++ if (ev->button == Button2) {
++ XConvertSelection(dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY,
++ utf8, utf8, win, CurrentTime);
++ drawmenu();
++ return;
++ }
++ /* scroll up */
++ if (ev->button == Button4 && prev) {
++ sel = curr = prev;
++ calcoffsets();
++ drawmenu();
++ return;
++ }
++ /* scroll down */
++ if (ev->button == Button5 && next) {
++ sel = curr = next;
++ calcoffsets();
++ drawmenu();
++ return;
++ }
++ if (ev->button != Button1)
++ return;
++ if (ev->state & ~ControlMask)
++ return;
++ if (lines > 0) {
++ /* vertical list: (ctrl)left-click on item */
++ w = mw - x;
++ for (item = curr; item != next; item = item->right) {
++ y += h;
++ if (ev->y >= y && ev->y <= (y + h)) {
++ puts(item->text);
++ if (!(ev->state & ControlMask))
++ exit(0);
++ sel = item;
++ if (sel) {
++ sel->out = 1;
++ drawmenu();
++ }
++ return;
++ }
++ }
++ } else if (matches) {
++ /* left-click on left arrow */
++ x += inputw;
++ w = TEXTW("<");
++ if (prev && curr->left) {
++ if (ev->x >= x && ev->x <= x + w) {
++ sel = curr = prev;
++ calcoffsets();
++ drawmenu();
++ return;
++ }
++ }
++ /* horizontal list: (ctrl)left-click on item */
++ for (item = curr; item != next; item = item->right) {
++ x += w;
++ w = MIN(TEXTW(item->text), mw - x - TEXTW(">"));
++ if (ev->x >= x && ev->x <= x + w) {
++ puts(item->text);
++ if (!(ev->state & ControlMask))
++ exit(0);
++ sel = item;
++ if (sel) {
++ sel->out = 1;
++ drawmenu();
++ }
++ return;
++ }
++ }
++ /* left-click on right arrow */
++ w = TEXTW(">");
++ x = mw - w;
++ if (next && ev->x >= x && ev->x <= x + w) {
++ sel = curr = next;
++ calcoffsets();
++ drawmenu();
++ return;
++ }
++ }
++}
++
+ static void
+ paste(void)
+ {
+@@ -582,6 +695,9 @@ run(void)
+ break;
+ cleanup();
+ exit(1);
++ case ButtonPress:
++ buttonpress(&ev);
++ break;
+ case Expose:
+ if (ev.xexpose.count == 0)
+ drw_map(drw, win, 0, 0, mw, mh);
+@@ -679,7 +795,8 @@ setup(void)
+ /* create menu window */
+ swa.override_redirect = True;
+ swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
+- swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
++ swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask |
++ ButtonPressMask;
+ win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
+ CopyFromParent, CopyFromParent, CopyFromParent,
+ CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
diff --git a/patches/5.dmenu-lineheight-5.0.diff b/patches/5.dmenu-lineheight-5.0.diff
new file mode 100644
index 0000000..3b0df3d
--- /dev/null
+++ b/patches/5.dmenu-lineheight-5.0.diff
@@ -0,0 +1,106 @@
+From ba103e38ea4ab07f9a3ee90627714b9bea17c329 Mon Sep 17 00:00:00 2001
+From: pskry <peter@skrypalle.dk>
+Date: Sun, 8 Nov 2020 22:04:22 +0100
+Subject: [PATCH] Add an option which defines the lineheight
+
+Despite both the panel and dmenu using the same font (a Terminus 12),
+dmenu is shorter and the panel is visible from under the dmenu bar.
+The appearance can be even more distracting when using similar colors
+for background and selections. With the option added by this patch,
+dmenu can be launched with a '-h 24', thus completely covering the panel.
+---
+ config.def.h | 3 +++
+ dmenu.1 | 5 +++++
+ dmenu.c | 11 ++++++++---
+ 3 files changed, 16 insertions(+), 3 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 1edb647..4394dec 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -15,6 +15,9 @@ static const char *colors[SchemeLast][2] = {
+ };
+ /* -l option; if nonzero, dmenu uses vertical list with given number of lines */
+ static unsigned int lines = 0;
++/* -h option; minimum height of a menu line */
++static unsigned int lineheight = 0;
++static unsigned int min_lineheight = 8;
+
+ /*
+ * Characters not considered part of a word while deleting words
+diff --git a/dmenu.1 b/dmenu.1
+index 323f93c..f2a82b4 100644
+--- a/dmenu.1
++++ b/dmenu.1
+@@ -6,6 +6,8 @@ dmenu \- dynamic menu
+ .RB [ \-bfiv ]
+ .RB [ \-l
+ .IR lines ]
++.RB [ \-h
++.IR height ]
+ .RB [ \-m
+ .IR monitor ]
+ .RB [ \-p
+@@ -50,6 +52,9 @@ dmenu matches menu items case insensitively.
+ .BI \-l " lines"
+ dmenu lists items vertically, with the given number of lines.
+ .TP
++.BI \-h " height"
++dmenu uses a menu line of at least 'height' pixels tall, but no less than 8.
++.TP
+ .BI \-m " monitor"
+ dmenu is displayed on the monitor number supplied. Monitor numbers are starting
+ from 0.
+diff --git a/dmenu.c b/dmenu.c
+index 65f25ce..f2a4047 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -131,7 +131,7 @@ drawmenu(void)
+ {
+ unsigned int curpos;
+ struct item *item;
+- int x = 0, y = 0, w;
++ int x = 0, y = 0, fh = drw->fonts->h, w;
+
+ drw_setscheme(drw, scheme[SchemeNorm]);
+ drw_rect(drw, 0, 0, mw, mh, 1, 1);
+@@ -148,7 +148,7 @@ drawmenu(void)
+ curpos = TEXTW(text) - TEXTW(&text[cursor]);
+ if ((curpos += lrpad / 2 - 1) < w) {
+ drw_setscheme(drw, scheme[SchemeNorm]);
+- drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0);
++ drw_rect(drw, x + curpos, 2 + (bh - fh) / 2, 2, fh - 4, 1, 0);
+ }
+
+ if (lines > 0) {
+@@ -609,6 +609,7 @@ setup(void)
+
+ /* calculate menu geometry */
+ bh = drw->fonts->h + 2;
++ bh = MAX(bh,lineheight); /* make a menu line AT LEAST 'lineheight' tall */
+ lines = MAX(lines, 0);
+ mh = (lines + 1) * bh;
+ #ifdef XINERAMA
+@@ -689,7 +690,7 @@ setup(void)
+ static void
+ usage(void)
+ {
+- fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
++ fputs("usage: dmenu [-bfiv] [-l lines] [-h height] [-p prompt] [-fn font] [-m monitor]\n"
+ " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr);
+ exit(1);
+ }
+@@ -717,6 +718,10 @@ main(int argc, char *argv[])
+ /* these options take one argument */
+ else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
+ lines = atoi(argv[++i]);
++ else if (!strcmp(argv[i], "-h")) { /* minimum height of one menu line */
++ lineheight = atoi(argv[++i]);
++ lineheight = MAX(lineheight, min_lineheight);
++ }
+ else if (!strcmp(argv[i], "-m"))
+ mon = atoi(argv[++i]);
+ else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
+--
+2.29.2
+