From 1d431d19b17b8bf362b323918f3c906ee858343f Mon Sep 17 00:00:00 2001 From: stkhan Date: Thu, 24 Jul 2025 19:02:41 -0500 Subject: Clean --- wm/dmenu-5.3/config.def.h | 1 + wm/dmenu-5.3/config.h | 1 + wm/dmenu-5.3/dmenu.1 | 3 + wm/dmenu-5.3/dmenu.1.orig | 210 ---------------------------- wm/dmenu-5.3/dmenu.c | 11 +- wm/dmenu-5.3/patches/dmenu-instant-5.3.diff | 88 ++++++++++++ 6 files changed, 103 insertions(+), 211 deletions(-) delete mode 100644 wm/dmenu-5.3/dmenu.1.orig create mode 100644 wm/dmenu-5.3/patches/dmenu-instant-5.3.diff (limited to 'wm/dmenu-5.3') diff --git a/wm/dmenu-5.3/config.def.h b/wm/dmenu-5.3/config.def.h index d336705..72f084c 100644 --- a/wm/dmenu-5.3/config.def.h +++ b/wm/dmenu-5.3/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; /* -n option; if 1, select single entry automatically */ static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */ static const unsigned int alpha = 0xff; /* Amount of opacity. 0xff is opaque */ /* -fn option overrides fonts[0]; default X11 font or font set */ diff --git a/wm/dmenu-5.3/config.h b/wm/dmenu-5.3/config.h index 7d4edc0..dcff6d6 100644 --- a/wm/dmenu-5.3/config.h +++ b/wm/dmenu-5.3/config.h @@ -1,6 +1,7 @@ /* See LICENSE file for copyright and license details. */ /* Default settings; can be overriden by command line. */ +static int instant = 1; static unsigned int lineheight = 0; static unsigned int min_lineheight = 8; static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */ diff --git a/wm/dmenu-5.3/dmenu.1 b/wm/dmenu-5.3/dmenu.1 index 89eb7bf..d17889f 100644 --- a/wm/dmenu-5.3/dmenu.1 +++ b/wm/dmenu-5.3/dmenu.1 @@ -63,6 +63,9 @@ dmenu matches menu items case insensitively. .BI \-g " columns" dmenu lists items in a grid with the given number of columns. .TP +.B \-n +dmenu instantly selects if only one match. +.TP .BI \-l " lines" dmenu lists items in a grid with the given number of lines. .TP diff --git a/wm/dmenu-5.3/dmenu.1.orig b/wm/dmenu-5.3/dmenu.1.orig deleted file mode 100644 index be710c7..0000000 --- a/wm/dmenu-5.3/dmenu.1.orig +++ /dev/null @@ -1,210 +0,0 @@ -.TH DMENU 1 dmenu\-VERSION -.SH NAME -dmenu \- dynamic menu -.SH SYNOPSIS -.B dmenu -.RB [ \-bfiv ] -.RB [ \-g -.IR columns ] -.RB [ \-l -.IR lines ] -.RB [ \-h -.IR height ] -.RB [ \-m -.IR monitor ] -.RB [ \-p -.IR prompt ] -.RB [ \-fn -.IR font ] -.RB [ \-nb -.IR color ] -.RB [ \-nf -.IR color ] -.RB [ \-sb -.IR color ] -.RB [ \-sf -.IR color ] -.RB [ \-w -.IR windowid ] -.P -.BR dmenu_run " ..." -.SH DESCRIPTION -.B dmenu -is a dynamic menu for X, which reads a list of newline\-separated items from -stdin. When the user selects an item and presses Return, their choice is printed -to stdout and dmenu terminates. Entering text will narrow the items to those -matching the tokens in the input. -.P -.B dmenu_run -is a script used by -.IR dwm (1) -which lists programs in the user's $PATH and runs the result in their $SHELL. -.SH OPTIONS -.TP -.B \-b -dmenu appears at the bottom of the screen. -.TP -.B \-c -dmenu appears centered on the screen. -.TP -.B \-f -dmenu grabs the keyboard before reading stdin if not reading from a tty. This -is faster, but will lock up X until stdin reaches end\-of\-file. -.TP -.B \-i -dmenu matches menu items case insensitively. -.TP -.BI \-g " columns" -dmenu lists items in a grid with the given number of columns. -.TP -.BI \-l " lines" -dmenu lists items in a grid with the given number of lines. -.TP -.BI \-lh " height" -dmenu uses a menu line of at least 'height' pixels tall, but no less than 8. -.TP -.BI \-h " height" -dmenu uses a menu line of at least 'height' pixels tall, but no less than 8. -.TP -.BI \-m " monitor" -dmenu is displayed on the monitor number supplied. Monitor numbers are starting -from 0. -.TP -.BI \-p " prompt" -defines the prompt to be displayed to the left of the input field. -.TP -.BI \-fn " font" -defines the font or font set used. -.TP -.BI \-nb " color" -defines the normal background color. -.IR #RGB , -.IR #RRGGBB , -and X color names are supported. -.TP -.BI \-nf " color" -defines the normal foreground color. -.TP -.BI \-sb " color" -defines the selected background color. -.TP -.BI \-sf " color" -defines the selected foreground color. -.TP -.B \-v -prints version information to stdout, then exits. -.TP -.BI \-w " windowid" -embed into windowid. -.SH USAGE -dmenu is completely controlled by the keyboard. Items are selected using the -arrow keys, page up, page down, home, and end. -.TP -.B Tab -Copy the selected item to the input field. -.TP -.B Return -Confirm selection. Prints the selected item to stdout and exits, returning -success. -.TP -.B Ctrl-Return -Confirm selection. Prints the selected item to stdout and continues. -.TP -.B Shift\-Return -Confirm input. Prints the input text to stdout and exits, returning success. -.TP -.B Escape -Exit without selecting an item, returning failure. -.TP -.B Ctrl-Left -Move cursor to the start of the current word -.TP -.B Ctrl-Right -Move cursor to the end of the current word -.TP -.B C\-a -Home -.TP -.B C\-b -Left -.TP -.B C\-c -Escape -.TP -.B C\-d -Delete -.TP -.B C\-e -End -.TP -.B C\-f -Right -.TP -.B C\-g -Escape -.TP -.B C\-h -Backspace -.TP -.B C\-i -Tab -.TP -.B C\-j -Return -.TP -.B C\-J -Shift-Return -.TP -.B C\-k -Delete line right -.TP -.B C\-m -Return -.TP -.B C\-M -Shift-Return -.TP -.B C\-n -Down -.TP -.B C\-p -Up -.TP -.B C\-u -Delete line left -.TP -.B C\-w -Delete word left -.TP -.B C\-y -Paste from primary X selection -.TP -.B C\-Y -Paste from X clipboard -.TP -.B M\-b -Move cursor to the start of the current word -.TP -.B M\-f -Move cursor to the end of the current word -.TP -.B M\-g -Home -.TP -.B M\-G -End -.TP -.B M\-h -Up -.TP -.B M\-j -Page down -.TP -.B M\-k -Page up -.TP -.B M\-l -Down -.SH SEE ALSO -.IR dwm (1), -.IR stest (1) diff --git a/wm/dmenu-5.3/dmenu.c b/wm/dmenu-5.3/dmenu.c index 504487c..8ce8aac 100644 --- a/wm/dmenu-5.3/dmenu.c +++ b/wm/dmenu-5.3/dmenu.c @@ -306,6 +306,13 @@ match(void) matchend = substrend; } curr = sel = matches; + + if (instant && matches && matches==matchend && !lsubstr) { + puts(matches->text); + cleanup(); + exit(0); + } + calcoffsets(); } @@ -789,7 +796,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], "-g")) { /* number of columns in grid */ diff --git a/wm/dmenu-5.3/patches/dmenu-instant-5.3.diff b/wm/dmenu-5.3/patches/dmenu-instant-5.3.diff new file mode 100644 index 0000000..0aefd08 --- /dev/null +++ b/wm/dmenu-5.3/patches/dmenu-instant-5.3.diff @@ -0,0 +1,88 @@ +From 26b302783a16dc2aa19451d9ba4515c8484f4a05 Mon Sep 17 00:00:00 2001 +From: Max Schillinger +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 +@@ -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 +@@ -3,7 +3,7 @@ + dmenu \- dynamic menu + .SH SYNOPSIS + .B dmenu +-.RB [ \-bfiv ] ++.RB [ \-bfinv ] + .RB [ \-l + .IR lines ] + .RB [ \-m +@@ -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 +@@ -277,6 +277,13 @@ match(void) + matchend = substrend; + } + curr = sel = matches; ++ ++ if (instant && matches && matches==matchend && !lsubstr) { ++ puts(matches->text); ++ cleanup(); ++ exit(0); ++ } ++ + calcoffsets(); + } + +@@ -715,7 +722,7 @@ setup(void) + static void + usage(void) + { +- die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" ++ die("usage: dmenu [-bfinv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" + " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]"); + } + +@@ -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 + -- cgit v1.2.3