Compare commits

..

7 Commits
0.7 ... 0.9

7 changed files with 52 additions and 38 deletions

View File

@ -4,3 +4,5 @@ d352e9dc112ee96aa5cad961a0ed880ae9ce7276 0.3
7acf0dde1120542917bae12e0e42293f9d2cc899 0.4
4a0ecd881c4fc15de4a0bebd79308b064be020ef 0.5
25f679fb19686140a907684ffcb423b9e9d44b53 0.6
5fc20d7158bd16b4d5f8d1c25e177680b6d54252 0.7
409667a57221f7e50ba8b5248f638915cd61b366 0.8

2
README
View File

@ -1,6 +1,6 @@
dmenu - dynamic menu
--------------------
dmenu is a generic, highly customizable, and efficient menu for X.
dmenu is a generic and efficient menu for X.
Requirements

View File

@ -8,3 +8,4 @@
#define SELFGCOLOR "#eeeeee"
#define NORMBGCOLOR "#333333"
#define NORMFGCOLOR "#dddddd"
#define STDIN_TIMEOUT 3 /* seconds */

View File

@ -8,3 +8,4 @@
#define SELFGCOLOR "#eeeeee"
#define NORMBGCOLOR "#333366"
#define NORMFGCOLOR "#cccccc"
#define STDIN_TIMEOUT 3 /* seconds */

View File

@ -1,5 +1,5 @@
# dmenu version
VERSION = 0.7
VERSION = 0.9
# Customize below to fit your system

59
dmenu.1
View File

@ -6,59 +6,54 @@ dmenu \- dynamic menu
.RB [ \-v ]
.SH DESCRIPTION
.SS Overview
.B dmenu
is a generic, highly customizable, and efficient menu for X,
originally designed for
dmenu is a generic menu for X, originally designed for
.BR dwm (1).
It supports arbitrary, user defined menu contents.
It manages huge amounts (up to 10.000 and more) of user defined menu items
efficiently.
.SS Options
.TP
.B \-v
prints version information to standard output, then exits.
.SH USAGE
.B dmenu
reads a list of newline-separated items from standard input and creates a menu.
When the user selects an item or enters any text and presses Return, his choice
is printed to standard output and
.B dmenu
terminates.
.B dmenu
is completely controlled by the keyboard. The following keys are recognized:
dmenu reads a list of newline-separated items from standard input and creates a
menu. When the user selects an item or enters any text and presses Return, his
choice is printed to standard output and dmenu terminates.
.P
dmenu is completely controlled by the keyboard. The following keys are recognized:
.TP
Any printable character
Appends the character to the text in the input field. This works as a filter:
.B Any printable character
Appends the character to the text in the input field. This works as a filter:
only items containing this text will be displayed.
.TP
Left/Right
.B Left/Right
Select the previous/next item.
.TP
Tab
.B Tab
Copy the selected item to the input field.
.TP
Return
Confirm selection and quit (print the selected item to standard output).
.B Return
Confirm selection and quit (print the selected item to standard output). Returns
.B 0
on termination.
.TP
Shift-Return
.B Shift-Return
Confirm selection and quit (print the text in the input field to standard output).
Returns
.B 0
on termination.
.TP
Escape
Quit without selecting an item.
.B Escape
Quit without selecting an item. Returns
.B 1
on termination.
.TP
Backspace (Control-h)
.B Backspace (Control-h)
Remove enough characters from the input field to change its filtering effect.
.TP
Control-u
.B Control-u
Remove all characters from the input field.
.P
.B dmenu
returns
.B 0
if Return is pressed on termination,
.B 1
if Escape is pressed.
.SH CUSTOMIZATION
.B dmenu
is customized by creating a custom config.h and (re)compiling the source
dmenu is customized by creating a custom config.h and (re)compiling the source
code. This keeps it fast, secure and simple.
.SH SEE ALSO
.BR dwm (1)

23
main.c
View File

@ -11,6 +11,8 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/select.h>
#include <sys/time.h>
#include <X11/cursorfont.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
@ -290,6 +292,8 @@ int
main(int argc, char *argv[])
{
char *maxname;
fd_set rd;
struct timeval timeout;
Item *i;
XEvent ev;
XSetWindowAttributes wa;
@ -307,13 +311,23 @@ main(int argc, char *argv[])
screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen);
maxname = readstdin();
/* grab as early as possible, but after reading all items!!! */
/* Note, the select() construction allows to grab all keypresses as
* early as possible, to not loose them. But if there is no standard
* input supplied, we will make sure to exit after MAX_WAIT_STDIN
* seconds. This is convenience behavior for rapid typers.
*/
while(XGrabKeyboard(dpy, root, True, GrabModeAsync,
GrabModeAsync, CurrentTime) != GrabSuccess)
usleep(1000);
timeout.tv_usec = 0;
timeout.tv_sec = STDIN_TIMEOUT;
FD_ZERO(&rd);
FD_SET(STDIN_FILENO, &rd);
if(select(ConnectionNumber(dpy) + 1, &rd, NULL, NULL, &timeout) < 1)
goto UninitializedEnd;
maxname = readstdin();
/* style */
dc.sel[ColBG] = getcolor(SELBGCOLOR);
dc.sel[ColFG] = getcolor(SELFGCOLOR);
@ -366,7 +380,6 @@ main(int argc, char *argv[])
}
}
XUngrabKeyboard(dpy, CurrentTime);
while(allitems) {
i = allitems->next;
free(allitems->text);
@ -380,6 +393,8 @@ main(int argc, char *argv[])
XFreePixmap(dpy, dc.drawable);
XFreeGC(dpy, dc.gc);
XDestroyWindow(dpy, win);
UninitializedEnd:
XUngrabKeyboard(dpy, CurrentTime);
XCloseDisplay(dpy);
return ret;