aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dmenu.122
-rw-r--r--dmenu.c18
2 files changed, 27 insertions, 13 deletions
diff --git a/dmenu.1 b/dmenu.1
index d2a93d1..a4fcfd9 100644
--- a/dmenu.1
+++ b/dmenu.1
@@ -4,6 +4,7 @@ dmenu \- dynamic menu
4.SH SYNOPSIS 4.SH SYNOPSIS
5.B dmenu 5.B dmenu
6.RB [ \-b ] 6.RB [ \-b ]
7.RB [ \-f ]
7.RB [ \-i ] 8.RB [ \-i ]
8.RB [ \-l 9.RB [ \-l
9.IR lines ] 10.IR lines ]
@@ -32,9 +33,9 @@ is a dynamic menu for X, originally designed for
32.BR dwm (1). 33.BR dwm (1).
33It manages huge numbers of user-defined menu items efficiently. 34It manages huge numbers of user-defined menu items efficiently.
34.P 35.P
35dmenu reads a list of newline-separated items from standard input and creates a 36dmenu reads a list of newline-separated items from stdin and creates a menu.
36menu. When the user selects an item or enters any text and presses Return, 37When the user selects an item or enters any text and presses Return, their
37their choice is printed to standard output and dmenu terminates. 38choice is printed to stdout and dmenu terminates.
38.P 39.P
39.B dmenu_run 40.B dmenu_run
40is a dmenu script used by dwm which lists programs in the user's PATH and 41is a dmenu script used by dwm which lists programs in the user's PATH and
@@ -47,6 +48,10 @@ is a program used by dmenu_run to find and cache a list of executables.
47.B \-b 48.B \-b
48dmenu appears at the bottom of the screen. 49dmenu appears at the bottom of the screen.
49.TP 50.TP
51.B \-f
52dmenu grabs the keyboard before reading stdin. This is faster, but may lock up
53X if stdin is from a terminal.
54.TP
50.B \-i 55.B \-i
51dmenu matches menu items case insensitively. 56dmenu matches menu items case insensitively.
52.TP 57.TP
@@ -66,7 +71,7 @@ defines the font or font set used.
66defines the normal background color. 71defines the normal background color.
67.IR #RGB , 72.IR #RGB ,
68.IR #RRGGBB , 73.IR #RRGGBB ,
69and color names are supported. 74and X color names are supported.
70.TP 75.TP
71.BI \-nf " color" 76.BI \-nf " color"
72defines the normal foreground color. 77defines the normal foreground color.
@@ -78,7 +83,7 @@ defines the selected background color.
78defines the selected foreground color. 83defines the selected foreground color.
79.TP 84.TP
80.B \-v 85.B \-v
81prints version information to standard output, then exits. 86prints version information to stdout, then exits.
82.SH USAGE 87.SH USAGE
83dmenu is completely controlled by the keyboard. Besides standard Unix line 88dmenu is completely controlled by the keyboard. Besides standard Unix line
84editing and item selection (Up/Down/Left/Right, PageUp/PageDown, Home/End), the 89editing and item selection (Up/Down/Left/Right, PageUp/PageDown, Home/End), the
@@ -88,12 +93,11 @@ following keys are recognized:
88Copy the selected item to the input field. 93Copy the selected item to the input field.
89.TP 94.TP
90.B Return (Control\-j) 95.B Return (Control\-j)
91Confirm selection. Prints the selected item to standard output and exits, 96Confirm selection. Prints the selected item to stdout and exits, returning
92returning success. 97success.
93.TP 98.TP
94.B Shift\-Return (Control\-Shift\-j) 99.B Shift\-Return (Control\-Shift\-j)
95Confirm input. Prints the input text to standard output and exits, returning 100Confirm input. Prints the input text to stdout and exits, returning success.
96success.
97.TP 101.TP
98.B Escape (Control\-c) 102.B Escape (Control\-c)
99Exit without selecting an item, returning failure. 103Exit without selecting an item, returning failure.
diff --git a/dmenu.c b/dmenu.c
index 5be73f7..2193f82 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -64,6 +64,7 @@ static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
64 64
65int 65int
66main(int argc, char *argv[]) { 66main(int argc, char *argv[]) {
67 Bool fast = False;
67 int i; 68 int i;
68 69
69 progname = "dmenu"; 70 progname = "dmenu";
@@ -77,6 +78,8 @@ main(int argc, char *argv[]) {
77 topbar = False; 78 topbar = False;
78 else if(!strcmp(argv[i], "-i")) 79 else if(!strcmp(argv[i], "-i"))
79 fstrncmp = strncasecmp; 80 fstrncmp = strncasecmp;
81 else if(!strcmp(argv[i], "-f"))
82 fast = True;
80 else if(i == argc-1) 83 else if(i == argc-1)
81 goto usage; 84 goto usage;
82 /* double flags */ 85 /* double flags */
@@ -101,13 +104,21 @@ main(int argc, char *argv[]) {
101 104
102 dc = initdc(); 105 dc = initdc();
103 initfont(dc, font); 106 initfont(dc, font);
104 readstdin(); 107
105 setup(); 108 if(fast) {
109 setup();
110 readstdin();
111 }
112 else {
113 readstdin();
114 setup();
115 }
116 match();
106 run(); 117 run();
107 return EXIT_FAILURE; 118 return EXIT_FAILURE;
108 119
109usage: 120usage:
110 fputs("usage: dmenu [-b] [-i] [-l lines] [-m monitor] [-p prompt] [-fn font]\n" 121 fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-m monitor] [-p prompt] [-fn font]\n"
111 " [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr); 122 " [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr);
112 return EXIT_FAILURE; 123 return EXIT_FAILURE;
113} 124}
@@ -530,5 +541,4 @@ setup(void) {
530 inputw = MIN(inputw, mw/3); 541 inputw = MIN(inputw, mw/3);
531 promptw = prompt ? textw(dc, prompt) : 0; 542 promptw = prompt ? textw(dc, prompt) : 0;
532 XMapRaised(dc->dpy, win); 543 XMapRaised(dc->dpy, win);
533 match();
534} 544}