diff options
author | Connor Lane Smith <cls@lubutu.com> | 2011-06-13 19:28:30 +0100 |
---|---|---|
committer | Connor Lane Smith <cls@lubutu.com> | 2011-06-13 19:28:30 +0100 |
commit | ab3bcac0bf42c1e63367a0f319a66524d5acdfe3 (patch) | |
tree | 6da0eb7147a6d4bc6ca7165d038c75cfe281b090 | |
parent | 723cbabc122292cc87474fd203e199e392206640 (diff) |
new lsx branch
-rw-r--r-- | Makefile | 21 | ||||
-rwxr-xr-x | dmenu_path | 2 | ||||
-rw-r--r-- | lsx.c | 43 |
3 files changed, 59 insertions, 7 deletions
@@ -3,10 +3,10 @@ | |||
3 | 3 | ||
4 | include config.mk | 4 | include config.mk |
5 | 5 | ||
6 | SRC = dmenu.c draw.c | 6 | SRC = dmenu.c draw.c lsx.c |
7 | OBJ = ${SRC:.c=.o} | 7 | OBJ = ${SRC:.c=.o} |
8 | 8 | ||
9 | all: options dmenu | 9 | all: options dmenu lsx |
10 | 10 | ||
11 | options: | 11 | options: |
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 | ||
23 | dmenu: ${OBJ} | 23 | dmenu: 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 | |||
27 | lsx: lsx.o | ||
28 | @echo CC -o $@ | ||
29 | @${CC} -o $@ lsx.o ${LDFLAGS} | ||
26 | 30 | ||
27 | clean: | 31 | clean: |
28 | @echo cleaning | 32 | @echo cleaning |
@@ -39,21 +43,26 @@ dist: clean | |||
39 | install: all | 43 | install: 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 | ||
51 | uninstall: | 58 | uninstall: |
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 |
@@ -3,7 +3,7 @@ CACHE=$HOME/.dmenu_cache | |||
3 | IFS=: | 3 | IFS=: |
4 | 4 | ||
5 | if ! test -f "$CACHE" || find $PATH -type d -newer "$CACHE" | grep -q .; then | 5 | if ! 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" |
7 | fi | 7 | fi |
8 | 8 | ||
9 | cat "$CACHE" | 9 | cat "$CACHE" |
@@ -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 | |||
9 | static void lsx(const char *s); | ||
10 | |||
11 | int | ||
12 | main(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 | |||
24 | void | ||
25 | lsx(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 | } | ||