[wiki] [sites] [dmenu][patch][tmenu] Update tmenu to apply cleanly on latest dmenu || Robert Bilski
commit 52b08dcc3ec76deb9559940b67c0a647e6fae09d
Author: Robert Bilski <robert_AT_rbilski.com>
Date: Thu Aug 15 20:00:43 2024 +0200
[dmenu][patch][tmenu] Update tmenu to apply cleanly on latest dmenu
diff --git a/tools.suckless.org/dmenu/patches/tmenu/dmenu-tmenu-20240811-475d809.diff b/tools.suckless.org/dmenu/patches/tmenu/dmenu-tmenu-20240811-475d809.diff
new file mode 100644
index 00000000..fd056ba7
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/tmenu/dmenu-tmenu-20240811-475d809.diff
_AT_@ -0,0 +1,114 @@
+From a90fe0dcad642e4c314d08a86f0848c7c5bc87cb Mon Sep 17 00:00:00 2001
+From: Robert Bilski <robert_AT_rbilski.com>
+Date: Sun, 11 Aug 2024 16:27:58 +0200
+Subject: [PATCH] Update tmenu patch
+
+---
+ config.def.h | 3 +++
+ dmenu.1 | 3 +++
+ dmenu.c | 25 +++++++++++++++++++------
+ 3 files changed, 25 insertions(+), 6 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 1edb647..805d8c4 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -21,3 +21,6 @@ static unsigned int lines = 0;
+ * for example: " /?\"&[]"
+ */
+ static const char worddelimiters[] = " ";
++
++/* delimiter for tmenu */
++static char valuedelimiter = ' ';
+diff --git a/dmenu.1 b/dmenu.1
+index 323f93c..fb22ed3 100644
+--- a/dmenu.1
++++ b/dmenu.1
+_AT_@ -47,6 +47,9 @@ is faster, but will lock up X until stdin reaches end\-of\-file.
+ .B \-i
+ dmenu matches menu items case insensitively.
+ .TP
++.BI \-d " tmenu delimiter"
++when used in a line, the value after the delimiter will be displayed. When selected, the value before the delimiter will be output. Only uses a single char as the delimiter.
++.TP
+ .BI \-l " lines"
+ dmenu lists items vertically, with the given number of lines.
+ .TP
+diff --git a/dmenu.c b/dmenu.c
+index 40f93e0..a456425 100644
+--- a/dmenu.c
++++ b/dmenu.c
+_AT_@ -28,7 +28,7 @@
+ enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
+
+ struct item {
+- char *text;
++ char *text, *value;
+ struct item *left, *right;
+ int out;
+ };
+_AT_@ -103,8 +103,8 @@ cleanup(void)
+ XUngrabKey(dpy, AnyKey, AnyModifier, root);
+ for (i = 0; i < SchemeLast; i++)
+ free(scheme[i]);
+- for (i = 0; items && items[i].text; ++i)
+- free(items[i].text);
++ for (i = 0; items && items[i].value; ++i)
++ free(items[i].value);
+ free(items);
+ drw_free(drw);
+ XSync(dpy, False);
+_AT_@ -489,7 +489,7 @@ insert:
+ break;
+ case XK_Return:
+ case XK_KP_Enter:
+- puts((sel && !(ev->state & ShiftMask)) ? sel->text : text);
++ puts((sel && !(ev->state & ShiftMask)) ? sel->value : text);
+ if (!(ev->state & ControlMask)) {
+ cleanup();
+ exit(0);
+_AT_@ -564,11 +564,22 @@ readstdin(void)
+ if (!(items[i].text = strdup(line)))
+ die("strdup:");
+
++ if (!(items[i].value = strdup(line)))
++ die("strdup:");
++
++ if ((items[i].text = strchr(items[i].value, valuedelimiter))) {
++ items[i].text[0] = '++ items[i].text++;
++ } else {
++ items[i].text = items[i].value;
++ }
+ items[i].out = 0;
+ }
+ free(line);
+- if (items)
++ if (items) {
+ items[i].text = NULL;
++ items[i].value = NULL;
++ }
+ lines = MIN(lines, i);
+ }
+
+_AT_@ -715,7 +726,7 @@ setup(void)
+ static void
+ usage(void)
+ {
+- die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]
"
++ die("usage: dmenu [-bfiv] [-d tmenu-delim] [-l lines] [-p prompt] [-fn font] [-m monitor]
"
+ " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
+ }
+
+_AT_@ -740,6 +751,8 @@ main(int argc, char *argv[])
+ } else if (i + 1 == argc)
+ usage();
+ /* these options take one argument */
++ else if (!strcmp(argv[i], "-d")) /* delimiter for tmenu */
++ valuedelimiter = argv[++i][0];
+ else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
+ lines = atoi(argv[++i]);
+ else if (!strcmp(argv[i], "-m"))
+--
+2.46.0
+
diff --git a/tools.suckless.org/dmenu/patches/tmenu/index.md b/tools.suckless.org/dmenu/patches/tmenu/index.md
index c2bc11b4..3c7d1d1c 100644
--- a/tools.suckless.org/dmenu/patches/tmenu/index.md
+++ b/tools.suckless.org/dmenu/patches/tmenu/index.md
_AT_@ -12,7 +12,9 @@ When the delimiter character is not present, the behavior is the same as w/o thi
Download
--------
* [dmenu-tmenu-5.2.diff](dmenu-tmenu-5.2.diff)
+* [dmenu-tmenu-20240811-475d809.diff](dmenu-tmenu-20240811-475d809.diff)
Author
------
* Tim Keller <tjk_AT_tjkeller.xyz>
+* Robert Bilski - <robert at rbilski com>
Received on Thu Aug 15 2024 - 20:01:14 CEST
This archive was generated by hypermail 2.3.0
: Thu Aug 15 2024 - 20:12:48 CEST