[wiki] [sites] [dmenu][patch][instant] Add patch for dmenu 5.3 || Max Schillinger

From: <git_AT_suckless.org>
Date: Tue, 27 Aug 2024 16:31:51 +0200

commit 3c9c84a7bf7812b305bf4dbe56bfe67b8a6d6353
Author: Max Schillinger <maxschillinger_AT_web.de>
Date: Tue Aug 27 16:31:22 2024 +0200

    [dmenu][patch][instant] Add patch for dmenu 5.3

diff --git a/tools.suckless.org/dmenu/patches/instant/dmenu-instant-5.3.diff b/tools.suckless.org/dmenu/patches/instant/dmenu-instant-5.3.diff
new file mode 100644
index 00000000..0aefd081
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/instant/dmenu-instant-5.3.diff
_AT_@ -0,0 +1,88 @@
+From 26b302783a16dc2aa19451d9ba4515c8484f4a05 Mon Sep 17 00:00:00 2001
+From: Max Schillinger <maxschillinger_AT_web.de>
+Date: Tue, 27 Aug 2024 16:19:41 +0200
+Subject: [PATCH] Instant mode
+
+Add '-n' flag to select the only (remaining) entry automatically.
+---
+ config.def.h | 1 +
+ dmenu.1 | 5 ++++-
+ dmenu.c | 13 +++++++++++--
+ 3 files changed, 16 insertions(+), 3 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 1edb647..7e6f1ed 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -1,6 +1,7 @@
+ /* See LICENSE file for copyright and license details. */
+ /* Default settings; can be overriden by command line. */
+
++static int instant = 0; /* -n option; if 1, select single entry automatically */
+ 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[] = {
+diff --git a/dmenu.1 b/dmenu.1
+index 323f93c..29bdf7f 100644
+--- a/dmenu.1
++++ b/dmenu.1
+_AT_@ -3,7 +3,7 @@
+ dmenu \- dynamic menu
+ .SH SYNOPSIS
+ .B dmenu
+-.RB [ \-bfiv ]
++.RB [ \-bfinv ]
+ .RB [ \-l
+ .IR lines ]
+ .RB [ \-m
+_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
++.B \-n
++dmenu instantly selects if only one match.
++.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..92d5154 100644
+--- a/dmenu.c
++++ b/dmenu.c
+_AT_@ -277,6 +277,13 @@ match(void)
+ matchend = substrend;
+ }
+ curr = sel = matches;
++
++ if (instant && matches && matches==matchend && !lsubstr) {
++ puts(matches->text);
++ cleanup();
++ exit(0);
++ }
++
+ calcoffsets();
+ }
+
+_AT_@ -715,7 +722,7 @@ setup(void)
+ static void
+ usage(void)
+ {
+- die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]
"
++ die("usage: dmenu [-bfinv] [-l lines] [-p prompt] [-fn font] [-m monitor]
"
+ " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
+ }
+
+_AT_@ -737,7 +744,9 @@ main(int argc, char *argv[])
+ else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
+ fstrncmp = strncasecmp;
+ fstrstr = cistrstr;
+- } else if (i + 1 == argc)
++ } else if (!strcmp(argv[i], "-n")) /* instant select only match */
++ instant = 1;
++ else if (i + 1 == argc)
+ usage();
+ /* these options take one argument */
+ else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
+--
+2.46.0
+
diff --git a/tools.suckless.org/dmenu/patches/instant/index.md b/tools.suckless.org/dmenu/patches/instant/index.md
index 9f088ba2..14a784e2 100644
--- a/tools.suckless.org/dmenu/patches/instant/index.md
+++ b/tools.suckless.org/dmenu/patches/instant/index.md
_AT_@ -1,14 +1,16 @@
 Instant Mode
 ============
-Adds an flag which will cause dmenu to select an item immediately if theres one
-matching option left.
+Adds a flag (`-n`) which will cause dmenu to select an item immediately when
+there's only one matching option left.
 
 Download
 --------
+* [dmenu-instant-5.3.diff](dmenu-instant-5.3.diff)
 * [dmenu-instant-4.7.diff](dmenu-instant-4.7.diff)
 * [dmenu-instant-4.6.diff](dmenu-instant-4.6.diff)
 * [dmenu-instant-20160702-3c91eed.diff](dmenu-instant-20160702-3c91eed.diff)
 
-Author
-------
-* Michael Stummvoll (stummi)<suckless_AT_stummi.org>
+Authors
+-------
+* Michael Stummvoll (stummi) <suckless_AT_stummi.org>
+* Max Schillinger <maxschillinger_AT_web.de> (5.3 version)
Received on Tue Aug 27 2024 - 16:31:51 CEST

This archive was generated by hypermail 2.3.0 : Tue Aug 27 2024 - 16:36:52 CEST