[hackers] [dmenu][PATCH] Allow only one dmenu_run selection

From: Christopher Lang <christopher.lang.256_AT_gmail.com>
Date: Wed, 30 Aug 2023 12:49:37 +0100

Using <CRTL>+<RETURN>, multiple selections can be make in dmenu, each
outputting on a new line. If multiple selections are made in dmenu_run
then multiple lines will be piped to $SHELL which will not be properly
handled.

This patch only pipes the last line of the output of dmenu to the shell.
In effect, the last or only program you selected is run.

I think its quite unintuitive that dmenu can output multiple lines, but
I understand removing the feature may break some users' scripts. Perhaps
a command option could be added to dissable multiple output.
---
 dmenu_run | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dmenu_run b/dmenu_run
index 834ede5..d6bbe5d 100755
--- a/dmenu_run
+++ b/dmenu_run
_AT_@ -1,2 +1,2 @@
 #!/bin/sh
-dmenu_path | dmenu "$_AT_" | ${SHELL:-"/bin/sh"} &
+dmenu_path | dmenu "$_AT_" | tail -n 1 | ${SHELL:-"/bin/sh"} &
-- 
2.42.0
Received on Wed Aug 30 2023 - 13:49:37 CEST

This archive was generated by hypermail 2.3.0 : Wed Aug 30 2023 - 14:12:54 CEST