Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
063c3d26e9 | |||
03c2b05bb2 | |||
8a066fabd9 | |||
6c0e05eb0d | |||
900d34347b | |||
4d0cc17794 | |||
28b6ea0f67 | |||
598d72fba9 | |||
007be12f2b | |||
6b5b580aff | |||
d8b48d64e1 | |||
a71424ac0e | |||
f1ab687c62 | |||
68a24f5535 | |||
47b37834c4 | |||
5f436fdcb7 | |||
de34639883 | |||
18592825d2 |
5
.hgtags
5
.hgtags
@ -21,3 +21,8 @@ c7f5f4d543170f03d70468e98a3a0ec8d2c4161b 1.9
|
|||||||
1fce5c464fcd870b9f024aa1853d5cf3a3eb371b 2.0
|
1fce5c464fcd870b9f024aa1853d5cf3a3eb371b 2.0
|
||||||
7656557298c954469a6a9564e6649b1fb5db663e 2.1
|
7656557298c954469a6a9564e6649b1fb5db663e 2.1
|
||||||
90f0e34e7f118c9ad3227a1606211ee825942b1c 2.2
|
90f0e34e7f118c9ad3227a1606211ee825942b1c 2.2
|
||||||
|
b6e09682c8adcb6569656bee73c311f9ab457715 2.3
|
||||||
|
9e9036cbfb4b7306c6fb366249e81dc0e65bdfde 2.4
|
||||||
|
03e83e2788c83ddd63b45a667939d7ec783c98cb 2.4.1
|
||||||
|
1ca5d430524e838c52ede912533cb90108c5cd66 2.4.2
|
||||||
|
041143e9fc544c62edc58af52cae9ac5237e5945 2.5
|
||||||
|
7
Makefile
7
Makefile
@ -32,7 +32,7 @@ clean:
|
|||||||
dist: clean
|
dist: clean
|
||||||
@echo creating dist tarball
|
@echo creating dist tarball
|
||||||
@mkdir -p dmenu-${VERSION}
|
@mkdir -p dmenu-${VERSION}
|
||||||
@cp -R LICENSE Makefile README config.mk dmenu.1 dmenu.h ${SRC} dmenu-${VERSION}
|
@cp -R LICENSE Makefile README config.mk dmenu.1 dmenu.h dmenu_path ${SRC} dmenu-${VERSION}
|
||||||
@tar -cf dmenu-${VERSION}.tar dmenu-${VERSION}
|
@tar -cf dmenu-${VERSION}.tar dmenu-${VERSION}
|
||||||
@gzip dmenu-${VERSION}.tar
|
@gzip dmenu-${VERSION}.tar
|
||||||
@rm -rf dmenu-${VERSION}
|
@rm -rf dmenu-${VERSION}
|
||||||
@ -40,8 +40,9 @@ dist: clean
|
|||||||
install: all
|
install: all
|
||||||
@echo installing executable file to ${DESTDIR}${PREFIX}/bin
|
@echo installing executable file to ${DESTDIR}${PREFIX}/bin
|
||||||
@mkdir -p ${DESTDIR}${PREFIX}/bin
|
@mkdir -p ${DESTDIR}${PREFIX}/bin
|
||||||
@cp -f dmenu ${DESTDIR}${PREFIX}/bin
|
@cp -f dmenu dmenu_path ${DESTDIR}${PREFIX}/bin
|
||||||
@chmod 755 ${DESTDIR}${PREFIX}/bin/dmenu
|
@chmod 755 ${DESTDIR}${PREFIX}/bin/dmenu
|
||||||
|
@chmod 755 ${DESTDIR}${PREFIX}/bin/dmenu_path
|
||||||
@echo installing manual page to ${DESTDIR}${MANPREFIX}/man1
|
@echo installing manual page to ${DESTDIR}${MANPREFIX}/man1
|
||||||
@mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
@mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
||||||
@sed "s/VERSION/${VERSION}/g" < dmenu.1 > ${DESTDIR}${MANPREFIX}/man1/dmenu.1
|
@sed "s/VERSION/${VERSION}/g" < dmenu.1 > ${DESTDIR}${MANPREFIX}/man1/dmenu.1
|
||||||
@ -49,7 +50,7 @@ install: all
|
|||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
@echo removing executable file from ${DESTDIR}${PREFIX}/bin
|
@echo removing executable file from ${DESTDIR}${PREFIX}/bin
|
||||||
@rm -f ${DESTDIR}${PREFIX}/bin/dmenu
|
@rm -f ${DESTDIR}${PREFIX}/bin/dmenu ${DESTDIR}${PREFIX}/bin/dmenu_path
|
||||||
@echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
|
@echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
|
||||||
@rm -f ${DESTDIR}${MANPREFIX}/man1/dmenu.1
|
@rm -f ${DESTDIR}${MANPREFIX}/man1/dmenu.1
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# dmenu version
|
# dmenu version
|
||||||
VERSION = 2.3
|
VERSION = 2.6
|
||||||
|
|
||||||
# Customize below to fit your system
|
# Customize below to fit your system
|
||||||
|
|
||||||
|
24
dmenu.1
24
dmenu.1
@ -1,4 +1,4 @@
|
|||||||
.TH DMENU 1 dmenu-VERSION
|
.TH DMENU 1 dmenu\-VERSION
|
||||||
.SH NAME
|
.SH NAME
|
||||||
dmenu \- dynamic menu
|
dmenu \- dynamic menu
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@ -53,41 +53,41 @@ dmenu is completely controlled by the keyboard. The following keys are recognize
|
|||||||
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
|
||||||
.B Left/Right (Mod1-h/Mod1-l)
|
.B Left/Right (Mod1\-h/Mod1\-l)
|
||||||
Select the previous/next item.
|
Select the previous/next item.
|
||||||
.TP
|
.TP
|
||||||
.B PageUp/PageDown (Mod1-k/Mod1-j)
|
.B PageUp/PageDown (Mod1\-k/Mod1\-j)
|
||||||
Select the first item of the previous/next 'page' of items.
|
Select the first item of the previous/next 'page' of items.
|
||||||
.TP
|
.TP
|
||||||
.B Home/End (Mod1-g/Mod1-G)
|
.B Home/End (Mod1\-g/Mod1\-G)
|
||||||
Select the first/last item.
|
Select the first/last item.
|
||||||
.TP
|
.TP
|
||||||
.B Tab (Control-i)
|
.B Tab (Control\-i)
|
||||||
Copy the selected item to the input field.
|
Copy the selected item to the input field.
|
||||||
.TP
|
.TP
|
||||||
.B Return (Control-j)
|
.B Return (Control\-j)
|
||||||
Confirm selection and quit (print the selected item to standard output). Returns
|
Confirm selection and quit (print the selected item to standard output). Returns
|
||||||
.B 0
|
.B 0
|
||||||
on termination.
|
on termination.
|
||||||
.TP
|
.TP
|
||||||
.B Shift-Return (Control-Shift-j)
|
.B Shift\-Return (Control\-Shift\-j)
|
||||||
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
|
Returns
|
||||||
.B 0
|
.B 0
|
||||||
on termination.
|
on termination.
|
||||||
.TP
|
.TP
|
||||||
.B Escape (Control-bracketleft)
|
.B Escape (Control\-bracketleft)
|
||||||
Quit without selecting an item. Returns
|
Quit without selecting an item. Returns
|
||||||
.B 1
|
.B 1
|
||||||
on termination.
|
on termination.
|
||||||
.TP
|
.TP
|
||||||
.B Backspace (Control-h)
|
.B Backspace (Control\-h)
|
||||||
Remove enough characters from the input field to change its filtering effect.
|
Remove a character from the input field.
|
||||||
.TP
|
.TP
|
||||||
.B Control-u
|
.B Control\-u
|
||||||
Remove all characters from the input field.
|
Remove all characters from the input field.
|
||||||
.TP
|
.TP
|
||||||
.B Control-w
|
.B Control\-w
|
||||||
Remove all characters of current word from the input field.
|
Remove all characters of current word from the input field.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR dwm (1),
|
.BR dwm (1),
|
||||||
|
41
dmenu.h
41
dmenu.h
@ -14,36 +14,31 @@
|
|||||||
/* color */
|
/* color */
|
||||||
enum { ColFG, ColBG, ColLast };
|
enum { ColFG, ColBG, ColLast };
|
||||||
|
|
||||||
typedef struct DC DC;
|
typedef struct {
|
||||||
typedef struct Fnt Fnt;
|
int x, y, w, h;
|
||||||
|
unsigned long norm[ColLast];
|
||||||
struct Fnt {
|
unsigned long sel[ColLast];
|
||||||
|
Drawable drawable;
|
||||||
|
GC gc;
|
||||||
|
struct {
|
||||||
XFontStruct *xfont;
|
XFontStruct *xfont;
|
||||||
XFontSet set;
|
XFontSet set;
|
||||||
int ascent;
|
int ascent;
|
||||||
int descent;
|
int descent;
|
||||||
int height;
|
int height;
|
||||||
};
|
} font;
|
||||||
|
} DC; /* draw context */
|
||||||
|
|
||||||
struct DC {
|
int screen;
|
||||||
int x, y, w, h;
|
Display *dpy;
|
||||||
unsigned long norm[ColLast];
|
DC dc; /* global drawing context */
|
||||||
unsigned long sel[ColLast];
|
|
||||||
Drawable drawable;
|
|
||||||
Fnt font;
|
|
||||||
GC gc;
|
|
||||||
}; /* draw context */
|
|
||||||
|
|
||||||
extern int screen;
|
|
||||||
extern Display *dpy;
|
|
||||||
extern DC dc; /* global drawing context */
|
|
||||||
|
|
||||||
/* draw.c */
|
/* draw.c */
|
||||||
extern void drawtext(const char *text, unsigned long col[ColLast]);
|
void drawtext(const char *text, unsigned long col[ColLast]);
|
||||||
extern unsigned int textw(const char *text);
|
unsigned int textw(const char *text);
|
||||||
extern unsigned int textnw(const char *text, unsigned int len);
|
unsigned int textnw(const char *text, unsigned int len);
|
||||||
|
|
||||||
/* util.c */
|
/* util.c */
|
||||||
extern void *emalloc(unsigned int size); /* allocates memory, exits on error */
|
void *emalloc(unsigned int size); /* allocates memory, exits on error */
|
||||||
extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */
|
void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */
|
||||||
extern char *estrdup(const char *str); /* duplicates str, exits on allocation error */
|
char *estrdup(const char *str); /* duplicates str, exits on allocation error */
|
||||||
|
9
dmenu_path
Executable file
9
dmenu_path
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
IFS=:
|
||||||
|
for dir in $PATH
|
||||||
|
do
|
||||||
|
for file in "$dir"/*
|
||||||
|
do
|
||||||
|
test -x "$file" && echo "${file##*/}"
|
||||||
|
done
|
||||||
|
done | sort | uniq
|
31
main.c
31
main.c
@ -108,6 +108,13 @@ drawmenu(void) {
|
|||||||
XFlush(dpy);
|
XFlush(dpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
grabkeyboard(void) {
|
||||||
|
while(XGrabKeyboard(dpy, root, True, GrabModeAsync,
|
||||||
|
GrabModeAsync, CurrentTime) != GrabSuccess)
|
||||||
|
usleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
static unsigned long
|
static unsigned long
|
||||||
initcolor(const char *colstr) {
|
initcolor(const char *colstr) {
|
||||||
Colormap cmap = DefaultColormap(dpy, screen);
|
Colormap cmap = DefaultColormap(dpy, screen);
|
||||||
@ -196,7 +203,7 @@ match(char *pattern) {
|
|||||||
static void
|
static void
|
||||||
kpress(XKeyEvent * e) {
|
kpress(XKeyEvent * e) {
|
||||||
char buf[32];
|
char buf[32];
|
||||||
int i, num, prev_nitem;
|
int i, num;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
KeySym ksym;
|
KeySym ksym;
|
||||||
|
|
||||||
@ -282,12 +289,8 @@ kpress(XKeyEvent * e) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case XK_BackSpace:
|
case XK_BackSpace:
|
||||||
if((i = len)) {
|
if(len) {
|
||||||
prev_nitem = nitem;
|
text[--len] = 0;
|
||||||
do {
|
|
||||||
text[--i] = 0;
|
|
||||||
match(text);
|
|
||||||
} while(i && nitem && prev_nitem == nitem);
|
|
||||||
match(text);
|
match(text);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -418,10 +421,6 @@ main(int argc, char *argv[]) {
|
|||||||
XModifierKeymap *modmap;
|
XModifierKeymap *modmap;
|
||||||
XSetWindowAttributes wa;
|
XSetWindowAttributes wa;
|
||||||
|
|
||||||
if(isatty(STDIN_FILENO)) {
|
|
||||||
fputs("error: dmenu can't run in an interactive shell\n", stdout);
|
|
||||||
usage();
|
|
||||||
}
|
|
||||||
/* command line args */
|
/* command line args */
|
||||||
for(i = 1; i < argc; i++)
|
for(i = 1; i < argc; i++)
|
||||||
if(!strncmp(argv[i], "-b", 3)) {
|
if(!strncmp(argv[i], "-b", 3)) {
|
||||||
@ -455,10 +454,14 @@ main(int argc, char *argv[]) {
|
|||||||
eprint("dmenu: cannot open display\n");
|
eprint("dmenu: cannot open display\n");
|
||||||
screen = DefaultScreen(dpy);
|
screen = DefaultScreen(dpy);
|
||||||
root = RootWindow(dpy, screen);
|
root = RootWindow(dpy, screen);
|
||||||
while(XGrabKeyboard(dpy, root, True, GrabModeAsync,
|
if(isatty(STDIN_FILENO)) {
|
||||||
GrabModeAsync, CurrentTime) != GrabSuccess)
|
|
||||||
usleep(1000);
|
|
||||||
maxname = readstdin();
|
maxname = readstdin();
|
||||||
|
grabkeyboard();
|
||||||
|
}
|
||||||
|
else { /* prevent keypress loss */
|
||||||
|
grabkeyboard();
|
||||||
|
maxname = readstdin();
|
||||||
|
}
|
||||||
/* init modifier map */
|
/* init modifier map */
|
||||||
modmap = XGetModifierMapping(dpy);
|
modmap = XGetModifierMapping(dpy);
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
|
Reference in New Issue
Block a user