aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config.def.h7
-rw-r--r--config.h7
-rw-r--r--dmenu.124
-rw-r--r--dmenu.c40
4 files changed, 67 insertions, 11 deletions
diff --git a/config.def.h b/config.def.h
index ce0a2d3..660ad96 100644
--- a/config.def.h
+++ b/config.def.h
@@ -2,7 +2,9 @@
/* Default settings; can be overriden by command line. */
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
-static int fuzzy = 1; /* -F option; if 0, dmenu doesn't use fuzzy matching */
+static const int user_bh =
+ 5; /* add an defined amount of pixels to the bar height */
+static int fuzzy = 1; /* -F option; if 0, dmenu doesn't use fuzzy matching */
/* -fn option overrides fonts[0]; default X11 font or font set */
static char font[] =
"DejaVuSansMono Nerd Font Mono:pixelsize=14;antialias=true;autohint=true";
@@ -24,6 +26,7 @@ static char *colors[SchemeLast][2] = {
[SchemeNorm] = {normfgcolor, normbgcolor},
[SchemeSel] = {selfgcolor, selbgcolor},
[SchemeOut] = {"#000000", "#00ffff"},
+ [SchemeMid] = {normfgcolor, normbgcolor},
[SchemeSelHighlight] = {"#ffc978", "#005577"},
[SchemeNormHighlight] = {"#ffc978", "#222222"},
};
@@ -50,4 +53,4 @@ ResourcePref resources[] = {
};
/* Size of the window border */
-static const unsigned int border_width = 5;
+static unsigned int border_width = 5;
diff --git a/config.h b/config.h
index ce0a2d3..660ad96 100644
--- a/config.h
+++ b/config.h
@@ -2,7 +2,9 @@
/* Default settings; can be overriden by command line. */
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
-static int fuzzy = 1; /* -F option; if 0, dmenu doesn't use fuzzy matching */
+static const int user_bh =
+ 5; /* add an defined amount of pixels to the bar height */
+static int fuzzy = 1; /* -F option; if 0, dmenu doesn't use fuzzy matching */
/* -fn option overrides fonts[0]; default X11 font or font set */
static char font[] =
"DejaVuSansMono Nerd Font Mono:pixelsize=14;antialias=true;autohint=true";
@@ -24,6 +26,7 @@ static char *colors[SchemeLast][2] = {
[SchemeNorm] = {normfgcolor, normbgcolor},
[SchemeSel] = {selfgcolor, selbgcolor},
[SchemeOut] = {"#000000", "#00ffff"},
+ [SchemeMid] = {normfgcolor, normbgcolor},
[SchemeSelHighlight] = {"#ffc978", "#005577"},
[SchemeNormHighlight] = {"#ffc978", "#222222"},
};
@@ -50,4 +53,4 @@ ResourcePref resources[] = {
};
/* Size of the window border */
-static const unsigned int border_width = 5;
+static unsigned int border_width = 5;
diff --git a/dmenu.1 b/dmenu.1
index b5c15d0..f3ab293 100644
--- a/dmenu.1
+++ b/dmenu.1
@@ -10,6 +10,12 @@ dmenu \- dynamic menu
.IR lines ]
.RB [ \-m
.IR monitor ]
+.RB [ \-x
+.IR xoffset ]
+.RB [ \-y
+.IR yoffset ]
+.RB [ \-z
+.IR width ]
.RB [ \-p
.IR prompt ]
.RB [ \-fn
@@ -73,6 +79,24 @@ dmenu lists items in a grid with the given number of columns.
dmenu is displayed on the monitor number supplied. Monitor numbers are starting
from 0.
.TP
+.BI \-x " xoffset"
+dmenu is placed at this offset measured from the left side of the monitor.
+Can be negative.
+If option
+.B \-m
+is present, the measurement will use the given monitor.
+.TP
+.BI \-y " yoffset"
+dmenu is placed at this offset measured from the top of the monitor. If the
+.B \-b
+option is used, the offset is measured from the bottom. Can be negative.
+If option
+.B \-m
+is present, the measurement will use the given monitor.
+.TP
+.BI \-z " width"
+sets the width of the dmenu window.
+.TP
.BI \-p " prompt"
defines the prompt to be displayed to the left of the input field.
.TP
diff --git a/dmenu.c b/dmenu.c
index 071e8c7..643b9b9 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -39,6 +39,7 @@ enum {
SchemeNormHighlight,
SchemeSelHighlight,
SchemeOut,
+ SchemeMid,
SchemeLast
}; /* color schemes */
@@ -58,6 +59,9 @@ static char separator;
static int separator_greedy;
static int separator_reverse;
static int bh, mw, mh;
+static int dmx = 0; /* put dmenu at this x offset */
+static int dmy = 0; /* put dmenu at this y offset (measured from the bottom if topbar is 0) */
+static unsigned int dmw = 0; /* make dmenu this wide */
static int inputw = 0, promptw;
static int lrpad; /* sum of left and right padding */
static size_t cursor;
@@ -204,6 +208,8 @@ static int drawitem(struct item *item, int x, int y, int w) {
int r;
if (item == sel)
drw_setscheme(drw, scheme[SchemeSel]);
+ else if (item->left == sel || item->right == sel)
+ drw_setscheme(drw, scheme[SchemeMid]);
else if (item->out)
drw_setscheme(drw, scheme[SchemeOut]);
else
@@ -984,7 +990,8 @@ static void setup(void) {
utf8 = XInternAtom(dpy, "UTF8_STRING", False);
/* calculate menu geometry */
- bh = drw->fonts->h + 2;
+ bh = drw->fonts->h;
+ bh = user_bh ? bh + user_bh : bh + 2;
lines = MAX(lines, 0);
mh = (lines + 1) * bh;
#ifdef XINERAMA
@@ -1015,18 +1022,24 @@ static void 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;
+ /* x = info[i].x_org; */
+ /* y = info[i].y_org + (topbar ? 0 : info[i].height - mh); */
+ /* mw = info[i].width; */
+ x = info[i].x_org + dmx;
+ y = info[i].y_org + (topbar ? dmy : info[i].height - mh - dmy);
+ mw = (dmw>0 ? dmw : info[i].width);;
XFree(info);
} else
#endif
{
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;
+ /* x = 0; */
+ /* y = topbar ? 0 : wa.height - mh; */
+ /* mw = wa.width; */
+ x = dmx;
+ y = topbar ? dmy : wa.height - mh - dmy;
+ mw = (dmw>0 ? dmw : wa.width);
}
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
inputw = MIN(inputw, mw / 3);
@@ -1040,6 +1053,8 @@ static void setup(void) {
win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width,
CopyFromParent, CopyFromParent, CopyFromParent,
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
+ if (border_width)
+ XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel);
XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel);
XSetClassHint(dpy, win, &ch);
@@ -1066,6 +1081,7 @@ static void setup(void) {
static void usage(void) {
fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
+ " [-x xoffset] [-y yoffset] [-z width]\n"
" [-nb color] [-nf color] [-sb color] [-sf color]\n"
" [-nhb color] [-nhf color] [-shb color] [-shf color]\n"
" [-d separator] [-D separator] [-dy command] [-w "
@@ -1088,6 +1104,8 @@ int main(int argc, char *argv[]) {
exit(0);
} else if (!strcmp(argv[i], "-b")) /* appears at the bottom of the screen */
topbar = 0;
+ else if (!strcmp(argv[i], "-t")) /* appears at the top of the screen */
+ topbar = 1;
else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
fast = 1;
else if (!strcmp(argv[i], "-F")) /* grabs keyboard before reading stdin */
@@ -1106,6 +1124,12 @@ int main(int argc, char *argv[]) {
lines = atoi(argv[++i]);
if (columns == 0)
columns = 1;
+ }else if (!strcmp(argv[i], "-x")) { /* window x offset */
+ dmx = atoi(argv[++i]);
+ }else if (!strcmp(argv[i], "-y")) { /* window y offset (from bottom up if -b) */
+ dmy = atoi(argv[++i]);
+ } else if (!strcmp(argv[i], "-z")) { /* make dmenu this wide */
+ dmw = atoi(argv[++i]);
} else if (!strcmp(argv[i], "-m"))
mon = atoi(argv[++i]);
else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
@@ -1136,6 +1160,8 @@ int main(int argc, char *argv[]) {
embed = argv[++i];
else if (!strcmp(argv[i], "-dy")) /* dynamic command to run */
dynamic = argv[++i] && *argv[i] ? argv[i] : NULL;
+ else if (!strcmp(argv[i], "-bw"))
+ border_width = atoi(argv[++i]); /* border width */
else
usage();