massive update to work with other tools
This commit is contained in:
parent
2a4b76bea3
commit
1a02648f15
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,6 @@
|
||||
.ccls-cache
|
||||
*.orig
|
||||
*.rej
|
||||
*.o
|
||||
dmenu
|
||||
stest
|
||||
|
6
config.h
6
config.h
@ -2,7 +2,7 @@
|
||||
/* Default settings; can be overriden by command line. */
|
||||
|
||||
/* -b option; if 0, dmenu appears at bottom */
|
||||
static int topbar = 0;
|
||||
static int topbar = 1;
|
||||
|
||||
/* -fn option overrides fonts[0]; default X11 font or font set */
|
||||
static const char *fonts[] = {
|
||||
@ -12,8 +12,8 @@ static const char *fonts[] = {
|
||||
/* -p option; prompt to the left of input field */
|
||||
static const char *prompt = NULL;
|
||||
|
||||
/* colours */
|
||||
#include "colours.h"
|
||||
/* theme */
|
||||
#include "themes/onedark.h"
|
||||
|
||||
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
|
||||
static unsigned int lines = 0;
|
||||
|
4
default.nix
Normal file
4
default.nix
Normal file
@ -0,0 +1,4 @@
|
||||
{ pkgs ? import <nixpkgs> {} }:
|
||||
pkgs.mkShell {
|
||||
nativeBuildInputs = [ pkgs.gnumake pkgs.pkg-config pkgs.xorg.libX11 pkgs.xorg.libXft pkgs.xorg.libXinerama ];
|
||||
}
|
24
dmenu.1
24
dmenu.1
@ -8,6 +8,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
|
||||
@ -54,6 +60,24 @@ dmenu lists items vertically, with the given number of lines.
|
||||
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
|
||||
|
22
dmenu.c
22
dmenu.c
@ -40,6 +40,9 @@ static char numbers[NUMBERSBUFSIZE] = "";
|
||||
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;
|
||||
@ -792,9 +795,9 @@ 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 + dmx;
|
||||
y = info[i].y_org + (topbar ? dmy : info[i].height - mh - dmy);
|
||||
mw = (dmw>0 ? dmw : info[i].width);
|
||||
XFree(info);
|
||||
} else
|
||||
#endif
|
||||
@ -802,9 +805,9 @@ 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;
|
||||
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);
|
||||
@ -846,6 +849,7 @@ 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] [-w windowid]\n", stderr);
|
||||
exit(1);
|
||||
}
|
||||
@ -873,6 +877,12 @@ 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], "-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 */
|
||||
|
@ -1,2 +1,2 @@
|
||||
#!/bin/sh
|
||||
dmenu_path | dmenu "$@" | ${SHELL:-"/bin/sh"} &
|
||||
/usr/local/bin/dmenu_path | /usr/local/bin/dmenu "$@" | ${SHELL:-"/bin/sh"} &
|
||||
|
116
patches/dmenu-xyw-5.0.diff
Normal file
116
patches/dmenu-xyw-5.0.diff
Normal file
@ -0,0 +1,116 @@
|
||||
From 7dc7cb96cdda9ad66e33109223c4cc297a7721d1 Mon Sep 17 00:00:00 2001
|
||||
From: Alex Cole <ajzcole@airmail.cc>
|
||||
Date: Tue, 6 Oct 2020 10:42:07 +1300
|
||||
Subject: [PATCH] Updated xyw for 5.0 properly
|
||||
|
||||
---
|
||||
dmenu.1 | 24 ++++++++++++++++++++++++
|
||||
dmenu.c | 22 ++++++++++++++++------
|
||||
2 files changed, 40 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/dmenu.1 b/dmenu.1
|
||||
index 323f93c..a4ecbbb 100644
|
||||
--- a/dmenu.1
|
||||
+++ b/dmenu.1
|
||||
@@ -8,6 +8,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
|
||||
@@ -54,6 +60,24 @@ dmenu lists items vertically, with the given number of lines.
|
||||
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 65f25ce..7be19ae 100644
|
||||
--- a/dmenu.c
|
||||
+++ b/dmenu.c
|
||||
@@ -37,6 +37,9 @@ struct item {
|
||||
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;
|
||||
@@ -637,9 +640,9 @@ 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 + dmx;
|
||||
+ y = info[i].y_org + (topbar ? dmy : info[i].height - mh - dmy);
|
||||
+ mw = (dmw>0 ? dmw : info[i].width);
|
||||
XFree(info);
|
||||
} else
|
||||
#endif
|
||||
@@ -647,9 +650,9 @@ 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;
|
||||
+ 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);
|
||||
@@ -690,6 +693,7 @@ 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] [-w windowid]\n", stderr);
|
||||
exit(1);
|
||||
}
|
||||
@@ -717,6 +721,12 @@ 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], "-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 */
|
||||
--
|
||||
2.28.0
|
||||
|
Loading…
Reference in New Issue
Block a user