aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile21
-rwxr-xr-xdmenu_path2
-rw-r--r--lsx.c43
3 files changed, 59 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 5871fa7..34a05b6 100644
--- a/Makefile
+++ b/Makefile
@@ -3,10 +3,10 @@
3 3
4include config.mk 4include config.mk
5 5
6SRC = dmenu.c draw.c 6SRC = dmenu.c draw.c lsx.c
7OBJ = ${SRC:.c=.o} 7OBJ = ${SRC:.c=.o}
8 8
9all: options dmenu 9all: options dmenu lsx
10 10
11options: 11options:
12 @echo dmenu build options: 12 @echo dmenu build options:
@@ -20,9 +20,13 @@ options:
20 20
21${OBJ}: config.mk 21${OBJ}: config.mk
22 22
23dmenu: ${OBJ} 23dmenu: dmenu.o draw.o
24 @echo CC -o $@ 24 @echo CC -o $@
25 @${CC} -o $@ ${OBJ} ${LDFLAGS} 25 @${CC} -o $@ dmenu.o draw.o ${LDFLAGS}
26
27lsx: lsx.o
28 @echo CC -o $@
29 @${CC} -o $@ lsx.o ${LDFLAGS}
26 30
27clean: 31clean:
28 @echo cleaning 32 @echo cleaning
@@ -39,21 +43,26 @@ dist: clean
39install: all 43install: all
40 @echo installing executables to ${DESTDIR}${PREFIX}/bin 44 @echo installing executables to ${DESTDIR}${PREFIX}/bin
41 @mkdir -p ${DESTDIR}${PREFIX}/bin 45 @mkdir -p ${DESTDIR}${PREFIX}/bin
42 @cp -f dmenu dmenu_path dmenu_run ${DESTDIR}${PREFIX}/bin 46 @cp -f dmenu dmenu_path dmenu_run lsx ${DESTDIR}${PREFIX}/bin
43 @chmod 755 ${DESTDIR}${PREFIX}/bin/dmenu 47 @chmod 755 ${DESTDIR}${PREFIX}/bin/dmenu
44 @chmod 755 ${DESTDIR}${PREFIX}/bin/dmenu_path 48 @chmod 755 ${DESTDIR}${PREFIX}/bin/dmenu_path
45 @chmod 755 ${DESTDIR}${PREFIX}/bin/dmenu_run 49 @chmod 755 ${DESTDIR}${PREFIX}/bin/dmenu_run
46 @echo installing manual page to ${DESTDIR}${MANPREFIX}/man1 50 @chmod 755 ${DESTDIR}${PREFIX}/bin/lsx
51 @echo installing manual pages to ${DESTDIR}${MANPREFIX}/man1
47 @mkdir -p ${DESTDIR}${MANPREFIX}/man1 52 @mkdir -p ${DESTDIR}${MANPREFIX}/man1
48 @sed "s/VERSION/${VERSION}/g" < dmenu.1 > ${DESTDIR}${MANPREFIX}/man1/dmenu.1 53 @sed "s/VERSION/${VERSION}/g" < dmenu.1 > ${DESTDIR}${MANPREFIX}/man1/dmenu.1
54 @sed "s/VERSION/${VERSION}/g" < lsx.1 > ${DESTDIR}${MANPREFIX}/man1/lsx.1
49 @chmod 644 ${DESTDIR}${MANPREFIX}/man1/dmenu.1 55 @chmod 644 ${DESTDIR}${MANPREFIX}/man1/dmenu.1
56 @chmod 644 ${DESTDIR}${MANPREFIX}/man1/lsx.1
50 57
51uninstall: 58uninstall:
52 @echo removing executables from ${DESTDIR}${PREFIX}/bin 59 @echo removing executables from ${DESTDIR}${PREFIX}/bin
53 @rm -f ${DESTDIR}${PREFIX}/bin/dmenu 60 @rm -f ${DESTDIR}${PREFIX}/bin/dmenu
54 @rm -f ${DESTDIR}${PREFIX}/bin/dmenu_path 61 @rm -f ${DESTDIR}${PREFIX}/bin/dmenu_path
55 @rm -f ${DESTDIR}${PREFIX}/bin/dmenu_run 62 @rm -f ${DESTDIR}${PREFIX}/bin/dmenu_run
63 @rm -f ${DESTDIR}${PREFIX}/bin/lsx
56 @echo removing manual page from ${DESTDIR}${MANPREFIX}/man1 64 @echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
57 @rm -f ${DESTDIR}${MANPREFIX}/man1/dmenu.1 65 @rm -f ${DESTDIR}${MANPREFIX}/man1/dmenu.1
66 @rm -f ${DESTDIR}${MANPREFIX}/man1/lsx.1
58 67
59.PHONY: all options clean dist install uninstall 68.PHONY: all options clean dist install uninstall
diff --git a/dmenu_path b/dmenu_path
index 1b1b241..81df5ed 100755
--- a/dmenu_path
+++ b/dmenu_path
@@ -3,7 +3,7 @@ CACHE=$HOME/.dmenu_cache
3IFS=: 3IFS=:
4 4
5if ! test -f "$CACHE" || find $PATH -type d -newer "$CACHE" | grep -q .; then 5if ! test -f "$CACHE" || find $PATH -type d -newer "$CACHE" | grep -q .; then
6 find $PATH ! -type d \( -perm -1 -o -perm -10 -o -perm -100 \) | sed 's/.*\///' | sort -u > "$CACHE" 6 lsx $PATH | sort -u > "$CACHE"
7fi 7fi
8 8
9cat "$CACHE" 9cat "$CACHE"
diff --git a/lsx.c b/lsx.c
new file mode 100644
index 0000000..7b84acc
--- /dev/null
+++ b/lsx.c
@@ -0,0 +1,43 @@
1/* See LICENSE file for copyright and license details. */
2#include <dirent.h>
3#include <stdio.h>
4#include <stdlib.h>
5#include <string.h>
6#include <unistd.h>
7#include <sys/stat.h>
8
9static void lsx(const char *s);
10
11int
12main(int argc, char *argv[]) {
13 int i;
14
15 if(argc < 2)
16 lsx(".");
17 else if(!strcmp(argv[1], "-v"))
18 puts("lsx-0.2, © 2006-2011 dmenu engineers, see LICENSE for details");
19 else for(i = 1; i < argc; i++)
20 lsx(argv[i]);
21 return EXIT_SUCCESS;
22}
23
24void
25lsx(const char *dir) {
26 char buf[PATH_MAX];
27 struct dirent *d;
28 struct stat st;
29 DIR *dp;
30
31 if(!(dp = opendir(dir))) {
32 perror(dir);
33 return;
34 }
35 while((d = readdir(dp))) {
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)
40 puts(d->d_name);
41 }
42 closedir(dp);
43}