summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.def.h4
-rw-r--r--config.def.h.orig26
-rw-r--r--config.h36
-rwxr-xr-xdmenubin42880 -> 43016 bytes
-rw-r--r--dmenu.13
-rw-r--r--dmenu.1.orig5
-rw-r--r--dmenu.c43
-rw-r--r--dmenu.c.orig9
-rw-r--r--dmenu.obin34752 -> 36344 bytes
9 files changed, 105 insertions, 21 deletions
diff --git a/config.def.h b/config.def.h
index bf9a338..28f5a89 100644
--- a/config.def.h
+++ b/config.def.h
@@ -2,6 +2,8 @@
/* Default settings; can be overriden by command line. */
static int topbar = 0; /* -b option; if 0, dmenu appears at bottom */
+static int centered = 0; /* -c option; centers dmenu on screen */
+static int min_width = 500; /* minimum width when centered */
/* -fn option overrides fonts[0]; default X11 font or font set */
static const char *fonts[] = {
"Sauce Code Pro:size=11"
@@ -19,7 +21,7 @@ static const char *colors[SchemeLast][2] = {
};
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
-static unsigned int lines = 3;
+static unsigned int lines = 12;
/* -h option; minimum height of a menu line */
static unsigned int lineheight = 24;
static unsigned int min_lineheight = 24;
diff --git a/config.def.h.orig b/config.def.h.orig
index a29eaa8..bf9a338 100644
--- a/config.def.h.orig
+++ b/config.def.h.orig
@@ -4,21 +4,25 @@
static int topbar = 0; /* -b option; if 0, dmenu appears at bottom */
/* -fn option overrides fonts[0]; default X11 font or font set */
static const char *fonts[] = {
- "Sauce Code Pro:size=12"
+ "Sauce Code Pro:size=11"
};
-static const char *prompt = "DMENU RUN: ";//NULL; /* -p option; prompt to the left of input field */
+static const char *prompt = "RUN: ";//NULL; /* -p option; prompt to the left of input field */
static const char *colors[SchemeLast][2] = {
/* fg bg */
- [SchemeNorm] = { "#FFFFFF", "#171520" },
- [SchemeSel] = { "#FFFFFF", "#D33682" },
- [SchemeSelHighlight] = { "#FFFFFF", "#5B76B7" },
- [SchemeNormHighlight] = { "#FFFFFF", "#130F23" },
- [SchemeMid] = { "#FFFFFF", "#8915e5" },
- /*[SchemeNormHighlight] = { "#FFFFFF", "#222222" },*/
- [SchemeOut] = { "#FFFFFF", "#5b76b7" },
+ [SchemeNorm] = { "#cccccc", "#282c34" },
+ [SchemeSel] = { "#1c1f24", "#c678dd" },
+ [SchemeSelHighlight] = { "#000000", "#51afef" },
+ [SchemeNormHighlight] = { "#000000", "#51afef" },
+ //[SchemeMid] = { "#000000", "#51afef" },
+ [SchemeMid] = { "#cccccc", "#282c34" },
+ [SchemeOut] = { "#d7d7d7", "#1c1f24" },
};
+
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
-static unsigned int lines = 0;
+static unsigned int lines = 3;
+/* -h option; minimum height of a menu line */
+static unsigned int lineheight = 24;
+static unsigned int min_lineheight = 24;
/*
* Characters not considered part of a word while deleting words
@@ -27,4 +31,4 @@ static unsigned int lines = 0;
static const char worddelimiters[] = " ";
/* Size of the window border */
-static unsigned int border_width = 0;
+static unsigned int border_width = 1;
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..19700b2
--- /dev/null
+++ b/config.h
@@ -0,0 +1,36 @@
+/* See LICENSE file for copyright and license details. */
+/* Default settings; can be overriden by command line. */
+
+static int topbar = 0; /* -b option; if 0, dmenu appears at bottom */
+static int centered = 0; /* -c option; centers dmenu on screen */
+static int min_width = 500; /* minimum width when centered */
+/* -fn option overrides fonts[0]; default X11 font or font set */
+static const char *fonts[] = {
+ "Sauce Code Pro:size=11"
+};
+static const char *prompt = "RUN: ";//NULL; /* -p option; prompt to the left of input field */
+static const char *colors[SchemeLast][2] = {
+ /* fg bg */
+ [SchemeNorm] = { "#cccccc", "#282c34" },
+ [SchemeSel] = { "#1c1f24", "#c678dd" },
+ [SchemeSelHighlight] = { "#000000", "#51afef" },
+ [SchemeNormHighlight] = { "#000000", "#51afef" },
+ //[SchemeMid] = { "#000000", "#51afef" },
+ [SchemeMid] = { "#cccccc", "#282c34" },
+ [SchemeOut] = { "#d7d7d7", "#1c1f24" },
+};
+
+/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
+static unsigned int lines = 3;
+/* -h option; minimum height of a menu line */
+static unsigned int lineheight = 24;
+static unsigned int min_lineheight = 24;
+
+/*
+ * Characters not considered part of a word while deleting words
+ * for example: " /?\"&[]"
+ */
+static const char worddelimiters[] = " ";
+
+/* Size of the window border */
+static unsigned int border_width = 1;
diff --git a/dmenu b/dmenu
index 1d83971..e01f982 100755
--- a/dmenu
+++ b/dmenu
Binary files differ
diff --git a/dmenu.1 b/dmenu.1
index 0d7f343..7591992 100644
--- a/dmenu.1
+++ b/dmenu.1
@@ -50,6 +50,9 @@ which lists programs in the user's $PATH and runs the result in their $SHELL.
.B \-b
dmenu appears at the bottom of the screen.
.TP
+.B \-c
+dmenu appears centered on the screen.
+.TP
.B \-f
dmenu grabs the keyboard before reading stdin if not reading from a tty. This
is faster, but will lock up X until stdin reaches end\-of\-file.
diff --git a/dmenu.1.orig b/dmenu.1.orig
index 472b179..0d7f343 100644
--- a/dmenu.1.orig
+++ b/dmenu.1.orig
@@ -6,6 +6,8 @@ dmenu \- dynamic menu
.RB [ \-bfiv ]
.RB [ \-l
.IR lines ]
+.RB [ \-h
+.IR height ]
.RB [ \-m
.IR monitor ]
.RB [ \-p
@@ -58,6 +60,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 4bdbb71..9f17c7d 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -96,6 +96,15 @@ calcoffsets(void)
break;
}
+static int
+max_textw(void)
+{
+ int len = 0;
+ for (struct item *item = items; item && item->text; item++)
+ len = MAX(TEXTW(item->text), len);
+ return len;
+}
+
static void
cleanup(void)
{
@@ -663,6 +672,7 @@ setup(void)
bh = MAX(bh,lineheight); /* make a menu line AT LEAST 'lineheight' tall */
lines = MAX(lines, 0);
mh = (lines + 1) * bh;
+ promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
#ifdef XINERAMA
i = 0;
if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) {
@@ -689,9 +699,16 @@ setup(void)
if (INTERSECT(x, y, 1, 1, info[i]))
break;
- x = info[i].x_org;
- y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
- mw = info[i].width;
+ if (centered) {
+ mw = MIN(MAX(max_textw() + promptw, min_width), info[i].width);
+ x = info[i].x_org + ((info[i].width - mw) / 2);
+ y = info[i].y_org + ((info[i].height - mh) / 2);
+ } else {
+ x = info[i].x_org;
+ y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
+ mw = info[i].width;
+ }
+
XFree(info);
} else
#endif
@@ -699,11 +716,17 @@ setup(void)
if (!XGetWindowAttributes(dpy, parentwin, &wa))
die("could not get embedding window attributes: 0x%lx",
parentwin);
- x = 0;
- y = topbar ? 0 : wa.height - mh;
- mw = wa.width;
+
+ if (centered) {
+ mw = MIN(MAX(max_textw() + promptw, min_width), wa.width);
+ x = (wa.width - mw) / 2;
+ y = (wa.height - mh) / 2;
+ } else {
+ x = 0;
+ y = topbar ? 0 : wa.height - mh;
+ mw = wa.width;
+ }
}
- promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
inputw = MIN(inputw, mw/3);
match();
@@ -764,6 +787,12 @@ main(int argc, char *argv[])
topbar = 0;
else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
fast = 1;
+ else if (!strcmp(argv[i], "-c")) /* centers dmenu on screen */
+ centered = 1;
+ else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
+ fstrncmp = strncasecmp;
+ fstrstr = cistrstr;
+ }
else if (!strcmp(argv[i], "-s")) { /* case-sensitive item matching */
fstrncmp = strncmp;
fstrstr = strstr;
diff --git a/dmenu.c.orig b/dmenu.c.orig
index 1bd6b76..4bdbb71 100644
--- a/dmenu.c.orig
+++ b/dmenu.c.orig
@@ -182,7 +182,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);
@@ -199,7 +199,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) {
@@ -660,6 +660,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
@@ -771,6 +772,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 */
diff --git a/dmenu.o b/dmenu.o
index 746bed2..00d636d 100644
--- a/dmenu.o
+++ b/dmenu.o
Binary files differ