aboutsummaryrefslogtreecommitdiffstats
path: root/dmenu.c
diff options
context:
space:
mode:
authorNikita Langer <nikitalanger@icloud.com>2026-07-13 18:15:00 +0200
committerNikita Langer <nikitalanger@icloud.com>2026-07-13 18:15:00 +0200
commit25bdca748a152441a0e4d7b1aee84d5edb3aac61 (patch)
tree79862b294b0a2369a68c81af29748f42891e1657 /dmenu.c
parent87407305553cbce9e6995614cccf3197f7d3aa3b (diff)
downloaddmenu-25bdca748a152441a0e4d7b1aee84d5edb3aac61.tar.gz
dmenu-25bdca748a152441a0e4d7b1aee84d5edb3aac61.tar.bz2
dmenu-25bdca748a152441a0e4d7b1aee84d5edb3aac61.tar.xz
dmenu-25bdca748a152441a0e4d7b1aee84d5edb3aac61.zip
xyz
Diffstat (limited to 'dmenu.c')
-rw-r--r--dmenu.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/dmenu.c b/dmenu.c
index ec5e004..6565563 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -47,6 +47,9 @@ typedef struct {
static char text[BUFSIZ] = "";
static char *embed;
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;
@@ -1058,9 +1061,9 @@ setup(void)
x = info[i].x_org + ((info[i].width - mw) / 2);
y = info[i].y_org + ((info[i].height - mh) / menu_height_ratio);
} else {
- 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);
@@ -1076,9 +1079,9 @@ setup(void)
x = (wa.width - mw) / 2;
y = (wa.height - mh) / 2;
} else {
- 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;
@@ -1124,6 +1127,7 @@ usage(void)
{
die("usage: dmenu [-bfiv] [-noi] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n"
+ " [-x xoffset] [-y yoffset] [-z width]\n"
" [-it text]\n", stderr);
}
@@ -1186,6 +1190,12 @@ main(int argc, char *argv[])
colors[SchemeOut][ColFg] = argv[++i];
else if (!strcmp(argv[i], "-w")) /* embedding window id */
embed = argv[++i];
+ 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], "-bw"))
border_width = atoi(argv[++i]); /* border width */
else if (!strcmp(argv[i], "-it")) { /* embedding window id */