dmenu

my build of dynamic menu
git clone git://git.kocotian.pl/dmenu.git
Log | Files | Refs | README | LICENSE

commit 9b73a5952fc98cf7e08b0ba540f4f4ec0dbd0da9
parent 9ad3c4665a0566ccc8851928fba8e6b21173c9b9
Author: kocotian <kocotian@kocotian.pl>
Date:   Wed, 30 Dec 2020 11:45:36 +0100

instant

Diffstat:
Mconfig.def.h | 1+
Mdmenu.1 | 5++++-
Mdmenu.c | 13+++++++++++--
Mpatches/dmenu-instant-4.7.diff | 0
4 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -1,6 +1,7 @@ /* See LICENSE file for copyright and license details. */ /* Default settings; can be overriden by command line. */ +static int instant = 0; static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */ static int fuzzy = 1; /* -F option; if 0, dmenu doesn't use fuzzy matching */ /* -fn option overrides fonts[0]; default X11 font or font set */ diff --git a/dmenu.1 b/dmenu.1 @@ -3,7 +3,7 @@ dmenu \- dynamic menu .SH SYNOPSIS .B dmenu -.RB [ \-bfiv ] +.RB [ \-bfinv ] .RB [ \-l .IR lines ] .RB [ \-h @@ -49,6 +49,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 @@ -349,6 +349,13 @@ match(void) matchend = substrend; } curr = sel = matches; + + if(instant && matches && matches==matchend && !lsubstr) { + puts(matches->text); + cleanup(); + exit(0); + } + calcoffsets(); } @@ -778,7 +785,7 @@ setup(void) static void usage(void) { - fputs("usage: dmenu [-bfiv] [-l lines] [-h height] [-p prompt] [-fn font] [-m monitor]\n" + fputs("usage: dmenu [-bfinv] [-l lines] [-h height] [-p prompt] [-fn font] [-m monitor]\n" " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr); exit(1); } @@ -805,7 +812,9 @@ main(int argc, char *argv[]) else if (!strcmp(argv[i], "-s")) { /* case-sensitive item matching */ fstrncmp = strncmp; fstrstr = strstr; - } 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 */ diff --git a/patches/dmenu-instant-4.7.diff b/patches/dmenu-instant-4.7.diff