aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor Lane Smith <cls@lubutu.com>2011-06-13 21:50:31 +0100
committerConnor Lane Smith <cls@lubutu.com>2011-06-13 21:50:31 +0100
commiteadf090413c530e69e8568492ebeb4b4087bd2ad (patch)
treecce8671f1d59e40a0bdc0be6c9ef379812ff8010
parent8ec1b41cacb33be39bc53fc67a4fe51d2d3ab3a0 (diff)
new dmenu_run
-rw-r--r--Makefile6
-rw-r--r--dmenu.111
-rwxr-xr-xdmenu_path9
-rwxr-xr-xdmenu_run9
-rw-r--r--lsx.c6
5 files changed, 15 insertions, 26 deletions
diff --git a/Makefile b/Makefile
index 34a05b6..f3f6b3d 100644
--- a/Makefile
+++ b/Makefile
@@ -35,7 +35,7 @@ clean:
35dist: clean 35dist: clean
36 @echo creating dist tarball 36 @echo creating dist tarball
37 @mkdir -p dmenu-${VERSION} 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 @tar -cf dmenu-${VERSION}.tar dmenu-${VERSION} 39 @tar -cf dmenu-${VERSION}.tar dmenu-${VERSION}
40 @gzip dmenu-${VERSION}.tar 40 @gzip dmenu-${VERSION}.tar
41 @rm -rf dmenu-${VERSION} 41 @rm -rf dmenu-${VERSION}
@@ -43,9 +43,8 @@ dist: clean
43install: all 43install: all
44 @echo installing executables to ${DESTDIR}${PREFIX}/bin 44 @echo installing executables to ${DESTDIR}${PREFIX}/bin
45 @mkdir -p ${DESTDIR}${PREFIX}/bin 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 @chmod 755 ${DESTDIR}${PREFIX}/bin/dmenu 47 @chmod 755 ${DESTDIR}${PREFIX}/bin/dmenu
48 @chmod 755 ${DESTDIR}${PREFIX}/bin/dmenu_path
49 @chmod 755 ${DESTDIR}${PREFIX}/bin/dmenu_run 48 @chmod 755 ${DESTDIR}${PREFIX}/bin/dmenu_run
50 @chmod 755 ${DESTDIR}${PREFIX}/bin/lsx 49 @chmod 755 ${DESTDIR}${PREFIX}/bin/lsx
51 @echo installing manual pages to ${DESTDIR}${MANPREFIX}/man1 50 @echo installing manual pages to ${DESTDIR}${MANPREFIX}/man1
@@ -58,7 +57,6 @@ install: all
58uninstall: 57uninstall:
59 @echo removing executables from ${DESTDIR}${PREFIX}/bin 58 @echo removing executables from ${DESTDIR}${PREFIX}/bin
60 @rm -f ${DESTDIR}${PREFIX}/bin/dmenu 59 @rm -f ${DESTDIR}${PREFIX}/bin/dmenu
61 @rm -f ${DESTDIR}${PREFIX}/bin/dmenu_path
62 @rm -f ${DESTDIR}${PREFIX}/bin/dmenu_run 60 @rm -f ${DESTDIR}${PREFIX}/bin/dmenu_run
63 @rm -f ${DESTDIR}${PREFIX}/bin/lsx 61 @rm -f ${DESTDIR}${PREFIX}/bin/lsx
64 @echo removing manual page from ${DESTDIR}${MANPREFIX}/man1 62 @echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
diff --git a/dmenu.1 b/dmenu.1
index 8295d17..44c953b 100644
--- a/dmenu.1
+++ b/dmenu.1
@@ -23,12 +23,10 @@ dmenu \- dynamic menu
23.RB [ \-v ] 23.RB [ \-v ]
24.P 24.P
25.BR dmenu_run " ..." 25.BR dmenu_run " ..."
26.P
27.B dmenu_path
28.SH DESCRIPTION 26.SH DESCRIPTION
29.B dmenu 27.B dmenu
30is a dynamic menu for X, originally designed for 28is a dynamic menu for X, originally designed for
31.BR dwm (1). 29.IR dwm (1).
32It manages huge numbers of user\-defined menu items efficiently. 30It manages huge numbers of user\-defined menu items efficiently.
33.P 31.P
34dmenu reads a list of newline\-separated items from stdin and creates a menu. 32dmenu reads a list of newline\-separated items from stdin and creates a menu.
@@ -36,11 +34,8 @@ When the user selects an item or enters any text and presses Return, their
36choice is printed to stdout and dmenu terminates. 34choice is printed to stdout and dmenu terminates.
37.P 35.P
38.B dmenu_run 36.B dmenu_run
39is a dmenu script used by dwm which lists programs in the user's PATH and 37is a dmenu script used by dwm which lists programs in the user's $PATH and
40executes the selected item. 38executes the selected item.
41.P
42.B dmenu_path
43is a script used by dmenu_run to find and cache a list of executables.
44.SH OPTIONS 39.SH OPTIONS
45.TP 40.TP
46.B \-b 41.B \-b
@@ -100,4 +95,4 @@ Exit without selecting an item, returning failure.
100.B Ctrl\-y 95.B Ctrl\-y
101Paste the current X selection into the input field. 96Paste the current X selection into the input field.
102.SH SEE ALSO 97.SH SEE ALSO
103.BR dwm (1) 98.IR dwm (1)
diff --git a/dmenu_path b/dmenu_path
deleted file mode 100755
index 81df5ed..0000000
--- a/dmenu_path
+++ /dev/null
@@ -1,9 +0,0 @@
1#!/bin/sh
2CACHE=$HOME/.dmenu_cache
3IFS=:
4
5if ! test -f "$CACHE" || find $PATH -type d -newer "$CACHE" | grep -q .; then
6 lsx $PATH | sort -u > "$CACHE"
7fi
8
9cat "$CACHE"
diff --git a/dmenu_run b/dmenu_run
index 3e1e6e4..6e96b38 100755
--- a/dmenu_run
+++ b/dmenu_run
@@ -1,2 +1,9 @@
1#!/bin/sh 1#!/bin/sh
2exe=`dmenu_path | dmenu ${1+"$@"}` && exec $exe 2CACHE=${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)
9cmd=`dmenu "$@" < "$CACHE"` && exec $cmd
diff --git a/lsx.c b/lsx.c
index 7b84acc..325c508 100644
--- a/lsx.c
+++ b/lsx.c
@@ -6,7 +6,7 @@
6#include <unistd.h> 6#include <unistd.h>
7#include <sys/stat.h> 7#include <sys/stat.h>
8 8
9static void lsx(const char *s); 9static void lsx(const char *dir);
10 10
11int 11int
12main(int argc, char *argv[]) { 12main(int argc, char *argv[]) {
@@ -34,9 +34,7 @@ lsx(const char *dir) {
34 } 34 }
35 while((d = readdir(dp))) { 35 while((d = readdir(dp))) {
36 snprintf(buf, sizeof buf, "%s/%s", dir, d->d_name); 36 snprintf(buf, sizeof buf, "%s/%s", dir, d->d_name);
37 if(stat(buf, &st) == -1) 37 if(stat(buf, &st) == 0 && S_ISREG(st.st_mode) && access(buf, X_OK) == 0)
38 perror(buf);
39 else if(S_ISREG(st.st_mode) && access(buf, X_OK) == 0)
40 puts(d->d_name); 38 puts(d->d_name);
41 } 39 }
42 closedir(dp); 40 closedir(dp);