From: Mohamed Rezk <[email protected]>

---
 dmenu.1 | 3 +++
 dmenu.c | 9 ++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/dmenu.1 b/dmenu.1
index 323f93c..5cea477 100644
--- a/dmenu.1
+++ b/dmenu.1
@@ -44,6 +44,9 @@ dmenu appears at the bottom of the screen.
 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 \-t
+dmenu grabs the keyboard output and prints it.
+.TP
 .B \-i
 dmenu matches menu items case insensitively.
 .TP
diff --git a/dmenu.c b/dmenu.c
index 27b7a30..ccd32ab 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -37,7 +37,7 @@ struct item {
 static char text[BUFSIZ] = "";
 static char *embed;
 static int bh, mw, mh;
-static int inputw = 0, promptw;
+static int inputw = 0, user_input = 0 ,promptw;
 static int lrpad; /* sum of left and right padding */
 static size_t cursor;
 static struct item *items = NULL;
@@ -553,6 +553,11 @@ readstdin(void)
        size_t i, junk, itemsiz = 0;
        ssize_t len;
 
+       if(user_input){
+       inputw = lines = 0;
+       return;
+       }
+
        /* read each line from stdin and add it to the item list */
        for (i = 0; (len = getline(&line, &junk, stdin)) != -1; i++) {
                if (i + 1 >= itemsiz) {
@@ -733,6 +738,8 @@ main(int argc, char *argv[])
                        topbar = 0;
                else if (!strcmp(argv[i], "-f"))   /* grabs keyboard before 
reading stdin */
                        fast = 1;
+               else if (!strcmp(argv[i], "-t"))   /* grabs keyboard output */
+                       user_input = 1;
                else if (!strcmp(argv[i], "-i")) { /* case-insensitive item 
matching */
                        fstrncmp = strncasecmp;
                        fstrstr = cistrstr;
-- 
2.39.2


Reply via email to