💾 Archived View for lord.re › posts › 103-remplacer-groovebasin › 103-dmenu-4.8-nograb.patch captured on 2024-12-17 at 09:59:47.

View Raw

More Information

⬅️ Previous capture (2024-09-29)

-=-=-=-=-=-=-

diff -ruN dmenu-4.8/config.h dmenu-4.8-nograb/config.h
--- dmenu-4.8/config.h	1970-01-01 01:00:00.000000000 +0100
+++ dmenu-4.8-nograb/config.h	2018-05-27 12:35:25.066883883 +0200
@@ -0,0 +1,23 @@
+/* See LICENSE file for copyright and license details. */
+/* Default settings; can be overriden by command line. */
+
+static int topbar = 1;                      /* -b  option; if 0, dmenu appears at bottom     */
+/* -fn option overrides fonts[0]; default X11 font or font set */
+static const char *fonts[] = {
+	"monospace:size=10"
+};
+static const char *prompt      = NULL;      /* -p  option; prompt to the left of input field */
+static const char *colors[SchemeLast][2] = {
+	/*     fg         bg       */
+	[SchemeNorm] = { "#bbbbbb", "#222222" },
+	[SchemeSel] = { "#eeeeee", "#005577" },
+	[SchemeOut] = { "#000000", "#00ffff" },
+};
+/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
+static unsigned int lines      = 0;
+
+/*
+ * Characters not considered part of a word while deleting words
+ * for example: " /?\"&[]"
+ */
+static const char worddelimiters[] = " ";
diff -ruN dmenu-4.8/dmenu.1 dmenu-4.8-nograb/dmenu.1
--- dmenu-4.8/dmenu.1	2018-03-14 20:26:40.000000000 +0100
+++ dmenu-4.8-nograb/dmenu.1	2018-05-27 12:55:23.142906123 +0200
@@ -47,6 +47,9 @@
 .B \-i
 dmenu matches menu items case insensitively.
 .TP
+.B \-g
+dmenu won't grab your keyboard focus (usefull to display notifications in conjunction with the timeout command).
+.TP
 .BI \-l " lines"
 dmenu lists items vertically, with the given number of lines.
 .TP
diff -ruN dmenu-4.8/dmenu.c dmenu-4.8-nograb/dmenu.c
--- dmenu-4.8/dmenu.c	2018-03-14 20:26:40.000000000 +0100
+++ dmenu-4.8-nograb/dmenu.c	2018-05-27 13:30:14.814944952 +0200
@@ -674,6 +674,7 @@
 usage(void)
 {
 	fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
+	      "             [-g]\n"
 	      "             [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr);
 	exit(1);
 }
@@ -682,7 +683,7 @@
 main(int argc, char *argv[])
 {
 	XWindowAttributes wa;
-	int i, fast = 0;
+	int i, fast = 0, focus = 1;
 
 	for (i = 1; i < argc; i++)
 		/* these options take no arguments */
@@ -693,6 +694,8 @@
 			topbar = 0;
 		else if (!strcmp(argv[i], "-f"))   /* grabs keyboard before reading stdin */
 			fast = 1;
+		else if (!strcmp(argv[i], "-g"))  /* no focus grab */
+			focus = 0;
 		else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
 			fstrncmp = strncasecmp;
 			fstrstr = cistrstr;
@@ -737,11 +740,16 @@
 	lrpad = drw->fonts->h;
 
 	if (fast) {
-		grabkeyboard();
-		readstdin();
+		if (focus) {
+			grabkeyboard();
+		} else {
+			readstdin();
+		}
 	} else {
 		readstdin();
-		grabkeyboard();
+		if (focus) {
+			grabkeyboard();
+		}
 	}
 	setup();
 	run();