commit ee7cbe6

hovercats  ·  2024-02-22 03:45:04 +0000 UTC
parent deb4e5d
dmenu: import
8 files changed,  +232, -0
+8, -0
1@@ -0,0 +1,8 @@
2+#!/bin/sh -e
3+
4+for p in *.patch; do
5+	patch -p1 < "$p"
6+done
7+
8+make LDFLAGS="$LDFLAGS -static"
9+make DESTDIR="$1" PREFIX=/ install
+4, -0
1@@ -0,0 +1,4 @@
2+c22ed9d7d2079f26f0ae2bcea5411e8515e887d9427dbd746ef2947a4fa87ba062
3+6b55b0be7cc2f1f339e3ec88ab0bc9e65007e04d36366c0cf900627069f11e4c28
4+2e6ff3de46fe11146128f38a402c234444bb037b44e155640da3831d950be7813a
5+30bcc44dabdc569164d618a0240c6e41b847c87f935490e85aa8f61e33cc07e07f
+2, -0
1@@ -0,0 +1,2 @@
2+libXft
3+libXinerama
+134, -0
  1@@ -0,0 +1,134 @@
  2+From 3e64cfceb4d343b241bebd869aa3ef8c7803d042 Mon Sep 17 00:00:00 2001
  3+From: hovercats <hovercatswithlasereyes@protonmail.com>
  4+Date: Wed, 29 Mar 2023 19:48:06 +0200
  5+Subject: [PATCH 1/4] apply center patch
  6+
  7+---
  8+ README       |  4 ++++
  9+ config.def.h |  2 ++
 10+ dmenu.1      |  3 +++
 11+ dmenu.c      | 38 ++++++++++++++++++++++++++++++++------
 12+ 4 files changed, 41 insertions(+), 6 deletions(-)
 13+
 14+diff --git a/README b/README
 15+index a8fcdfe..313b7aa 100644
 16+--- a/README
 17++++ b/README
 18+@@ -2,6 +2,10 @@ dmenu - dynamic menu
 19+ ====================
 20+ dmenu is an efficient dynamic menu for X.
 21+ 
 22++patches/changes
 23++---------------
 24++	- center patch
 25++
 26+ 
 27+ Requirements
 28+ ------------
 29+diff --git a/config.def.h b/config.def.h
 30+index 1edb647..88ef264 100644
 31+--- a/config.def.h
 32++++ b/config.def.h
 33+@@ -2,6 +2,8 @@
 34+ /* Default settings; can be overriden by command line. */
 35+ 
 36+ static int topbar = 1;                      /* -b  option; if 0, dmenu appears at bottom     */
 37++static int centered = 0;                    /* -c option; centers dmenu on screen */
 38++static int min_width = 500;                    /* minimum width when centered */
 39+ /* -fn option overrides fonts[0]; default X11 font or font set */
 40+ static const char *fonts[] = {
 41+ 	"monospace:size=10"
 42+diff --git a/dmenu.1 b/dmenu.1
 43+index 323f93c..c036baa 100644
 44+--- a/dmenu.1
 45++++ b/dmenu.1
 46+@@ -40,6 +40,9 @@ which lists programs in the user's $PATH and runs the result in their $SHELL.
 47+ .B \-b
 48+ dmenu appears at the bottom of the screen.
 49+ .TP
 50++.B \-c
 51++dmenu appears centered on the screen.
 52++.TP
 53+ .B \-f
 54+ dmenu grabs the keyboard before reading stdin if not reading from a tty. This
 55+ is faster, but will lock up X until stdin reaches end\-of\-file.
 56+diff --git a/dmenu.c b/dmenu.c
 57+index 4e7df12..5edb037 100644
 58+--- a/dmenu.c
 59++++ b/dmenu.c
 60+@@ -96,6 +96,15 @@ calcoffsets(void)
 61+ 			break;
 62+ }
 63+ 
 64++static int
 65++max_textw(void)
 66++{
 67++	int len = 0;
 68++	for (struct item *item = items; item && item->text; item++)
 69++		len = MAX(TEXTW(item->text), len);
 70++	return len;
 71++}
 72++
 73+ static void
 74+ cleanup(void)
 75+ {
 76+@@ -637,6 +646,7 @@ setup(void)
 77+ 	bh = drw->fonts->h + 2;
 78+ 	lines = MAX(lines, 0);
 79+ 	mh = (lines + 1) * bh;
 80++	promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
 81+ #ifdef XINERAMA
 82+ 	i = 0;
 83+ 	if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) {
 84+@@ -663,9 +673,16 @@ setup(void)
 85+ 				if (INTERSECT(x, y, 1, 1, info[i]) != 0)
 86+ 					break;
 87+ 
 88+-		x = info[i].x_org;
 89+-		y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
 90+-		mw = info[i].width;
 91++		if (centered) {
 92++			mw = MIN(MAX(max_textw() + promptw, min_width), info[i].width);
 93++			x = info[i].x_org + ((info[i].width  - mw) / 2);
 94++			y = info[i].y_org + ((info[i].height - mh) / 2);
 95++		} else {
 96++			x = info[i].x_org;
 97++			y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
 98++			mw = info[i].width;
 99++		}
100++
101+ 		XFree(info);
102+ 	} else
103+ #endif
104+@@ -673,9 +690,16 @@ setup(void)
105+ 		if (!XGetWindowAttributes(dpy, parentwin, &wa))
106+ 			die("could not get embedding window attributes: 0x%lx",
107+ 			    parentwin);
108+-		x = 0;
109+-		y = topbar ? 0 : wa.height - mh;
110+-		mw = wa.width;
111++
112++		if (centered) {
113++			mw = MIN(MAX(max_textw() + promptw, min_width), wa.width);
114++			x = (wa.width  - mw) / 2;
115++			y = (wa.height - mh) / 2;
116++		} else {
117++			x = 0;
118++			y = topbar ? 0 : wa.height - mh;
119++			mw = wa.width;
120++		}
121+ 	}
122+ 	promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
123+ 	inputw = mw / 3; /* input width: ~33% of monitor width */
124+@@ -734,6 +758,8 @@ main(int argc, char *argv[])
125+ 			topbar = 0;
126+ 		else if (!strcmp(argv[i], "-f"))   /* grabs keyboard before reading stdin */
127+ 			fast = 1;
128++		else if (!strcmp(argv[i], "-c"))   /* centers dmenu on screen */
129++			centered = 1;
130+ 		else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
131+ 			fstrncmp = strncasecmp;
132+ 			fstrstr = cistrstr;
133+-- 
134+2.42.0
135+
+50, -0
 1@@ -0,0 +1,50 @@
 2+From 531ffb3347100945c4e95951e9304bed7cee97cb Mon Sep 17 00:00:00 2001
 3+From: hovercats <hovercatswithlasereyes@protonmail.com>
 4+Date: Wed, 29 Mar 2023 20:18:05 +0200
 5+Subject: [PATCH 3/4] add border patch
 6+
 7+---
 8+ config.def.h | 3 +++
 9+ dmenu.c      | 6 +++++-
10+ 3 files changed, 9 insertions(+), 1 deletion(-)
11+
12+diff --git a/config.def.h b/config.def.h
13+index 88ef264..be7f0d2 100644
14+--- a/config.def.h
15++++ b/config.def.h
16+@@ -23,3 +23,6 @@ static unsigned int lines      = 0;
17+  * for example: " /?\"&[]"
18+  */
19+ static const char worddelimiters[] = " ";
20++
21++/* Size of the window border */
22++static unsigned int border_width = 2;
23+diff --git a/dmenu.c b/dmenu.c
24+index 5edb037..3c6f6da 100644
25+--- a/dmenu.c
26++++ b/dmenu.c
27+@@ -709,9 +709,11 @@ setup(void)
28+ 	swa.override_redirect = True;
29+ 	swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
30+ 	swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
31+-	win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
32++	win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width,
33+ 	                    CopyFromParent, CopyFromParent, CopyFromParent,
34+ 	                    CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
35++	if (border_width)
36++		XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel);
37+ 	XSetClassHint(dpy, win, &ch);
38+ 
39+ 
40+@@ -784,6 +786,8 @@ main(int argc, char *argv[])
41+ 			colors[SchemeSel][ColFg] = argv[++i];
42+ 		else if (!strcmp(argv[i], "-w"))   /* embedding window id */
43+ 			embed = argv[++i];
44++		else if (!strcmp(argv[i], "-bw"))
45++			border_width = atoi(argv[++i]); /* border width */
46+ 		else
47+ 			usage();
48+ 
49+-- 
50+2.42.0
51+
+29, -0
 1@@ -0,0 +1,29 @@
 2+From df687b9478c0de1f2d7fd1288d214a0812499c58 Mon Sep 17 00:00:00 2001
 3+From: hovercats <hovercatswithlasereyes@protonmail.com>
 4+Date: Sat, 1 Apr 2023 05:38:34 +0200
 5+Subject: [PATCH 4/4] change colorscheme
 6+
 7+---
 8+ config.def.h | 6 +++---
 9+ 1 file changed, 3 insertions(+), 3 deletions(-)
10+
11+diff --git a/config.def.h b/config.def.h
12+index be7f0d2..6a40966 100644
13+--- a/config.def.h
14++++ b/config.def.h
15+@@ -11,9 +11,9 @@ static const char *fonts[] = {
16+ static const char *prompt      = NULL;      /* -p  option; prompt to the left of input field */
17+ static const char *colors[SchemeLast][2] = {
18+ 	/*     fg         bg       */
19+-	[SchemeNorm] = { "#bbbbbb", "#222222" },
20+-	[SchemeSel] = { "#eeeeee", "#005577" },
21+-	[SchemeOut] = { "#000000", "#00ffff" },
22++	[SchemeNorm] = { "#e8e9ca", "#222222" },
23++	[SchemeSel] = { "#e8e9ca", "#4a708b" },
24++	[SchemeOut] = { "#4c4c4c", "#00ffff" },
25+ };
26+ /* -l option; if nonzero, dmenu uses vertical list with given number of lines */
27+ static unsigned int lines      = 0;
28+-- 
29+2.42.0
30+
+4, -0
1@@ -0,0 +1,4 @@
2+https://dl.suckless.org/tools/dmenu-5.2.tar.gz
3+patches/0001-apply-center-patch.patch
4+patches/0002-add-border-patch.patch
5+patches/0003-change-colorscheme.patch
+1, -0
1@@ -0,0 +1 @@
2+5.2 2