diff options
-rw-r--r-- | dmenu.1 | 22 | ||||
-rw-r--r-- | dmenu.c | 18 |
2 files changed, 27 insertions, 13 deletions
@@ -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). |
33 | It manages huge numbers of user-defined menu items efficiently. | 34 | It manages huge numbers of user-defined menu items efficiently. |
34 | .P | 35 | .P |
35 | dmenu reads a list of newline-separated items from standard input and creates a | 36 | dmenu reads a list of newline-separated items from stdin and creates a menu. |
36 | menu. When the user selects an item or enters any text and presses Return, | 37 | When the user selects an item or enters any text and presses Return, their |
37 | their choice is printed to standard output and dmenu terminates. | 38 | choice is printed to stdout and dmenu terminates. |
38 | .P | 39 | .P |
39 | .B dmenu_run | 40 | .B dmenu_run |
40 | is a dmenu script used by dwm which lists programs in the user's PATH and | 41 | is 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 |
48 | dmenu appears at the bottom of the screen. | 49 | dmenu appears at the bottom of the screen. |
49 | .TP | 50 | .TP |
51 | .B \-f | ||
52 | dmenu grabs the keyboard before reading stdin. This is faster, but may lock up | ||
53 | X if stdin is from a terminal. | ||
54 | .TP | ||
50 | .B \-i | 55 | .B \-i |
51 | dmenu matches menu items case insensitively. | 56 | dmenu matches menu items case insensitively. |
52 | .TP | 57 | .TP |
@@ -66,7 +71,7 @@ defines the font or font set used. | |||
66 | defines the normal background color. | 71 | defines the normal background color. |
67 | .IR #RGB , | 72 | .IR #RGB , |
68 | .IR #RRGGBB , | 73 | .IR #RRGGBB , |
69 | and color names are supported. | 74 | and X color names are supported. |
70 | .TP | 75 | .TP |
71 | .BI \-nf " color" | 76 | .BI \-nf " color" |
72 | defines the normal foreground color. | 77 | defines the normal foreground color. |
@@ -78,7 +83,7 @@ defines the selected background color. | |||
78 | defines the selected foreground color. | 83 | defines the selected foreground color. |
79 | .TP | 84 | .TP |
80 | .B \-v | 85 | .B \-v |
81 | prints version information to standard output, then exits. | 86 | prints version information to stdout, then exits. |
82 | .SH USAGE | 87 | .SH USAGE |
83 | dmenu is completely controlled by the keyboard. Besides standard Unix line | 88 | dmenu is completely controlled by the keyboard. Besides standard Unix line |
84 | editing and item selection (Up/Down/Left/Right, PageUp/PageDown, Home/End), the | 89 | editing and item selection (Up/Down/Left/Right, PageUp/PageDown, Home/End), the |
@@ -88,12 +93,11 @@ following keys are recognized: | |||
88 | Copy the selected item to the input field. | 93 | Copy the selected item to the input field. |
89 | .TP | 94 | .TP |
90 | .B Return (Control\-j) | 95 | .B Return (Control\-j) |
91 | Confirm selection. Prints the selected item to standard output and exits, | 96 | Confirm selection. Prints the selected item to stdout and exits, returning |
92 | returning success. | 97 | success. |
93 | .TP | 98 | .TP |
94 | .B Shift\-Return (Control\-Shift\-j) | 99 | .B Shift\-Return (Control\-Shift\-j) |
95 | Confirm input. Prints the input text to standard output and exits, returning | 100 | Confirm input. Prints the input text to stdout and exits, returning success. |
96 | success. | ||
97 | .TP | 101 | .TP |
98 | .B Escape (Control\-c) | 102 | .B Escape (Control\-c) |
99 | Exit without selecting an item, returning failure. | 103 | Exit without selecting an item, returning failure. |
@@ -64,6 +64,7 @@ static int (*fstrncmp)(const char *, const char *, size_t) = strncmp; | |||
64 | 64 | ||
65 | int | 65 | int |
66 | main(int argc, char *argv[]) { | 66 | main(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 | ||
109 | usage: | 120 | usage: |
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 | } |