Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
32f7fe4835 | |||
0fa5a339ff | |||
358f078c0b | |||
1f207893e6 | |||
1c5be1c553 | |||
32ea45084b | |||
cc7d863b6e |
2
.hgtags
2
.hgtags
@ -4,3 +4,5 @@ d352e9dc112ee96aa5cad961a0ed880ae9ce7276 0.3
|
|||||||
7acf0dde1120542917bae12e0e42293f9d2cc899 0.4
|
7acf0dde1120542917bae12e0e42293f9d2cc899 0.4
|
||||||
4a0ecd881c4fc15de4a0bebd79308b064be020ef 0.5
|
4a0ecd881c4fc15de4a0bebd79308b064be020ef 0.5
|
||||||
25f679fb19686140a907684ffcb423b9e9d44b53 0.6
|
25f679fb19686140a907684ffcb423b9e9d44b53 0.6
|
||||||
|
5fc20d7158bd16b4d5f8d1c25e177680b6d54252 0.7
|
||||||
|
409667a57221f7e50ba8b5248f638915cd61b366 0.8
|
||||||
|
2
README
2
README
@ -1,6 +1,6 @@
|
|||||||
dmenu - dynamic menu
|
dmenu - dynamic menu
|
||||||
--------------------
|
--------------------
|
||||||
dmenu is a generic, highly customizable, and efficient menu for X.
|
dmenu is a generic and efficient menu for X.
|
||||||
|
|
||||||
|
|
||||||
Requirements
|
Requirements
|
||||||
|
@ -8,3 +8,4 @@
|
|||||||
#define SELFGCOLOR "#eeeeee"
|
#define SELFGCOLOR "#eeeeee"
|
||||||
#define NORMBGCOLOR "#333333"
|
#define NORMBGCOLOR "#333333"
|
||||||
#define NORMFGCOLOR "#dddddd"
|
#define NORMFGCOLOR "#dddddd"
|
||||||
|
#define STDIN_TIMEOUT 3 /* seconds */
|
||||||
|
@ -8,3 +8,4 @@
|
|||||||
#define SELFGCOLOR "#eeeeee"
|
#define SELFGCOLOR "#eeeeee"
|
||||||
#define NORMBGCOLOR "#333366"
|
#define NORMBGCOLOR "#333366"
|
||||||
#define NORMFGCOLOR "#cccccc"
|
#define NORMFGCOLOR "#cccccc"
|
||||||
|
#define STDIN_TIMEOUT 3 /* seconds */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# dmenu version
|
# dmenu version
|
||||||
VERSION = 0.7
|
VERSION = 0.9
|
||||||
|
|
||||||
# Customize below to fit your system
|
# Customize below to fit your system
|
||||||
|
|
||||||
|
59
dmenu.1
59
dmenu.1
@ -6,59 +6,54 @@ dmenu \- dynamic menu
|
|||||||
.RB [ \-v ]
|
.RB [ \-v ]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.SS Overview
|
.SS Overview
|
||||||
.B dmenu
|
dmenu is a generic menu for X, originally designed for
|
||||||
is a generic, highly customizable, and efficient menu for X,
|
|
||||||
originally designed for
|
|
||||||
.BR dwm (1).
|
.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
|
.SS Options
|
||||||
.TP
|
.TP
|
||||||
.B \-v
|
.B \-v
|
||||||
prints version information to standard output, then exits.
|
prints version information to standard output, then exits.
|
||||||
.SH USAGE
|
.SH USAGE
|
||||||
.B dmenu
|
dmenu reads a list of newline-separated items from standard input and creates a
|
||||||
reads a list of newline-separated items from standard input and creates a menu.
|
menu. When the user selects an item or enters any text and presses Return, his
|
||||||
When the user selects an item or enters any text and presses Return, his choice
|
choice is printed to standard output and dmenu terminates.
|
||||||
is printed to standard output and
|
.P
|
||||||
.B dmenu
|
dmenu is completely controlled by the keyboard. The following keys are recognized:
|
||||||
terminates.
|
|
||||||
.B dmenu
|
|
||||||
is completely controlled by the keyboard. The following keys are recognized:
|
|
||||||
.TP
|
.TP
|
||||||
Any printable character
|
.B Any printable character
|
||||||
Appends the character to the text in the input field. This works as a filter:
|
Appends the character to the text in the input field. This works as a filter:
|
||||||
only items containing this text will be displayed.
|
only items containing this text will be displayed.
|
||||||
.TP
|
.TP
|
||||||
Left/Right
|
.B Left/Right
|
||||||
Select the previous/next item.
|
Select the previous/next item.
|
||||||
.TP
|
.TP
|
||||||
Tab
|
.B Tab
|
||||||
Copy the selected item to the input field.
|
Copy the selected item to the input field.
|
||||||
.TP
|
.TP
|
||||||
Return
|
.B Return
|
||||||
Confirm selection and quit (print the selected item to standard output).
|
Confirm selection and quit (print the selected item to standard output). Returns
|
||||||
|
.B 0
|
||||||
|
on termination.
|
||||||
.TP
|
.TP
|
||||||
Shift-Return
|
.B Shift-Return
|
||||||
Confirm selection and quit (print the text in the input field to standard output).
|
Confirm selection and quit (print the text in the input field to standard output).
|
||||||
|
Returns
|
||||||
|
.B 0
|
||||||
|
on termination.
|
||||||
.TP
|
.TP
|
||||||
Escape
|
.B Escape
|
||||||
Quit without selecting an item.
|
Quit without selecting an item. Returns
|
||||||
|
.B 1
|
||||||
|
on termination.
|
||||||
.TP
|
.TP
|
||||||
Backspace (Control-h)
|
.B Backspace (Control-h)
|
||||||
Remove enough characters from the input field to change its filtering effect.
|
Remove enough characters from the input field to change its filtering effect.
|
||||||
.TP
|
.TP
|
||||||
Control-u
|
.B Control-u
|
||||||
Remove all characters from the input field.
|
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
|
.SH CUSTOMIZATION
|
||||||
.B dmenu
|
dmenu is customized by creating a custom config.h and (re)compiling the source
|
||||||
is customized by creating a custom config.h and (re)compiling the source
|
|
||||||
code. This keeps it fast, secure and simple.
|
code. This keeps it fast, secure and simple.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR dwm (1)
|
.BR dwm (1)
|
||||||
|
23
main.c
23
main.c
@ -11,6 +11,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <sys/select.h>
|
||||||
|
#include <sys/time.h>
|
||||||
#include <X11/cursorfont.h>
|
#include <X11/cursorfont.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
@ -290,6 +292,8 @@ int
|
|||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *maxname;
|
char *maxname;
|
||||||
|
fd_set rd;
|
||||||
|
struct timeval timeout;
|
||||||
Item *i;
|
Item *i;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
XSetWindowAttributes wa;
|
XSetWindowAttributes wa;
|
||||||
@ -307,13 +311,23 @@ main(int argc, char *argv[])
|
|||||||
screen = DefaultScreen(dpy);
|
screen = DefaultScreen(dpy);
|
||||||
root = RootWindow(dpy, screen);
|
root = RootWindow(dpy, screen);
|
||||||
|
|
||||||
maxname = readstdin();
|
/* Note, the select() construction allows to grab all keypresses as
|
||||||
|
* early as possible, to not loose them. But if there is no standard
|
||||||
/* grab as early as possible, but after reading all items!!! */
|
* 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,
|
while(XGrabKeyboard(dpy, root, True, GrabModeAsync,
|
||||||
GrabModeAsync, CurrentTime) != GrabSuccess)
|
GrabModeAsync, CurrentTime) != GrabSuccess)
|
||||||
usleep(1000);
|
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 */
|
/* style */
|
||||||
dc.sel[ColBG] = getcolor(SELBGCOLOR);
|
dc.sel[ColBG] = getcolor(SELBGCOLOR);
|
||||||
dc.sel[ColFG] = getcolor(SELFGCOLOR);
|
dc.sel[ColFG] = getcolor(SELFGCOLOR);
|
||||||
@ -366,7 +380,6 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XUngrabKeyboard(dpy, CurrentTime);
|
|
||||||
while(allitems) {
|
while(allitems) {
|
||||||
i = allitems->next;
|
i = allitems->next;
|
||||||
free(allitems->text);
|
free(allitems->text);
|
||||||
@ -380,6 +393,8 @@ main(int argc, char *argv[])
|
|||||||
XFreePixmap(dpy, dc.drawable);
|
XFreePixmap(dpy, dc.drawable);
|
||||||
XFreeGC(dpy, dc.gc);
|
XFreeGC(dpy, dc.gc);
|
||||||
XDestroyWindow(dpy, win);
|
XDestroyWindow(dpy, win);
|
||||||
|
UninitializedEnd:
|
||||||
|
XUngrabKeyboard(dpy, CurrentTime);
|
||||||
XCloseDisplay(dpy);
|
XCloseDisplay(dpy);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user