new dmenu_run eadf0904
Connor Lane Smith · 2011-06-13 21:50 5 file(s) · +15 −26
Makefile +2 −4
35 35
dist: clean
36 36
	@echo creating dist tarball
37 37
	@mkdir -p dmenu-${VERSION}
38 -
	@cp LICENSE Makefile README config.mk dmenu.1 draw.h dmenu_path dmenu_run ${SRC} dmenu-${VERSION}
38 +
	@cp LICENSE Makefile README config.mk dmenu.1 draw.h dmenu_run ${SRC} dmenu-${VERSION}
39 39
	@tar -cf dmenu-${VERSION}.tar dmenu-${VERSION}
40 40
	@gzip dmenu-${VERSION}.tar
41 41
	@rm -rf dmenu-${VERSION}
43 43
install: all
44 44
	@echo installing executables to ${DESTDIR}${PREFIX}/bin
45 45
	@mkdir -p ${DESTDIR}${PREFIX}/bin
46 -
	@cp -f dmenu dmenu_path dmenu_run lsx ${DESTDIR}${PREFIX}/bin
46 +
	@cp -f dmenu dmenu_run lsx ${DESTDIR}${PREFIX}/bin
47 47
	@chmod 755 ${DESTDIR}${PREFIX}/bin/dmenu
48 -
	@chmod 755 ${DESTDIR}${PREFIX}/bin/dmenu_path
49 48
	@chmod 755 ${DESTDIR}${PREFIX}/bin/dmenu_run
50 49
	@chmod 755 ${DESTDIR}${PREFIX}/bin/lsx
51 50
	@echo installing manual pages to ${DESTDIR}${MANPREFIX}/man1
58 57
uninstall:
59 58
	@echo removing executables from ${DESTDIR}${PREFIX}/bin
60 59
	@rm -f ${DESTDIR}${PREFIX}/bin/dmenu
61 -
	@rm -f ${DESTDIR}${PREFIX}/bin/dmenu_path
62 60
	@rm -f ${DESTDIR}${PREFIX}/bin/dmenu_run
63 61
	@rm -f ${DESTDIR}${PREFIX}/bin/lsx
64 62
	@echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
dmenu.1 +3 −8
23 23
.RB [ \-v ]
24 24
.P
25 25
.BR dmenu_run " ..."
26 -
.P
27 -
.B dmenu_path
28 26
.SH DESCRIPTION
29 27
.B dmenu
30 28
is a dynamic menu for X, originally designed for
31 -
.BR dwm (1).
29 +
.IR dwm (1).
32 30
It manages huge numbers of user\-defined menu items efficiently.
33 31
.P
34 32
dmenu reads a list of newline\-separated items from stdin and creates a menu.
36 34
choice is printed to stdout and dmenu terminates.
37 35
.P
38 36
.B dmenu_run
39 -
is a dmenu script used by dwm which lists programs in the user's PATH and
37 +
is a dmenu script used by dwm which lists programs in the user's $PATH and
40 38
executes the selected item.
41 -
.P
42 -
.B dmenu_path
43 -
is a script used by dmenu_run to find and cache a list of executables.
44 39
.SH OPTIONS
45 40
.TP
46 41
.B \-b
100 95
.B Ctrl\-y
101 96
Paste the current X selection into the input field.
102 97
.SH SEE ALSO
103 -
.BR dwm (1)
98 +
.IR dwm (1)
dmenu_path (deleted) +0 −9
1 -
#!/bin/sh
2 -
CACHE=$HOME/.dmenu_cache
3 -
IFS=:
4 -
5 -
if ! test -f "$CACHE" || find $PATH -type d -newer "$CACHE" | grep -q .; then
6 -
	lsx $PATH | sort -u > "$CACHE"
7 -
fi
8 -
9 -
cat "$CACHE"
dmenu_run +8 −1
1 1
#!/bin/sh
2 -
exe=`dmenu_path | dmenu ${1+"$@"}` && exec $exe
2 +
CACHE=${XDG_CACHE_HOME:-"$HOME/.cache"}/dmenu_run
3 +
(
4 +
	IFS=:
5 +
	if test "`ls -dt $PATH "$CACHE" 2> /dev/null | sed 1q`" != "$CACHE"; then
6 +
		mkdir -p "`dirname "$CACHE"`" && lsx $PATH | sort -u > "$CACHE"
7 +
	fi
8 +
)
9 +
cmd=`dmenu "$@" < "$CACHE"` && exec $cmd
lsx.c +2 −4
6 6
#include <unistd.h>
7 7
#include <sys/stat.h>
8 8
9 -
static void lsx(const char *s);
9 +
static void lsx(const char *dir);
10 10
11 11
int
12 12
main(int argc, char *argv[]) {
34 34
	}
35 35
	while((d = readdir(dp))) {
36 36
		snprintf(buf, sizeof buf, "%s/%s", dir, d->d_name);
37 -
		if(stat(buf, &st) == -1)
38 -
			perror(buf);
39 -
		else if(S_ISREG(st.st_mode) && access(buf, X_OK) == 0)
37 +
		if(stat(buf, &st) == 0 && S_ISREG(st.st_mode) && access(buf, X_OK) == 0)
40 38
			puts(d->d_name);
41 39
	}
42 40
	closedir(dp);