1 diff -r 2b9683c50723 config.mk
2 --- a/config.mk Wed Dec 01 20:25:10 2010 +0000
3 +++ b/config.mk Thu Dec 30 12:37:58 2010 -0700
5 XINERAMALIBS = -lXinerama
6 XINERAMAFLAGS = -DXINERAMA
8 +# XDG path stuff, comment if you don't want it
9 +XDGBASEDIRLIBS = "-lxdg-basedir"
10 +XDGBASEDIRFLAGS = "-DXDGBASEDIR"
14 -LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS}
15 +LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${XDGBASEDIRLIBS}
18 -CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
19 +CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} ${XDGBASEDIRFLAGS}
20 CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
23 diff -r 2b9683c50723 dmenu_path.c
24 --- a/dmenu_path.c Wed Dec 01 20:25:10 2010 +0000
25 +++ b/dmenu_path.c Thu Dec 30 12:37:58 2010 -0700
30 -#define CACHE ".dmenu_cache"
32 + #include <basedir.h>
33 + #include <basedir_fs.h>
36 + #define CACHEDIR "/dmenu"
37 + #define CACHEFILE "/path.cache"
39 + static char *cachefile;
41 + #define CACHE ".dmenu_cache"
44 static void die(const char *s);
45 static int qstrcmp(const void *a, const void *b);
46 static void scan(void);
47 static int uptodate(void);
48 +static const char * getCacheFile(void);
50 static char **items = NULL;
51 static const char *home, *path;
56 - execlp("cat", "cat", CACHE, NULL);
57 + execlp("cat", "cat", getCacheFile(), NULL);
64 qsort(items, count, sizeof *items, qstrcmp);
65 - if(!(cache = fopen(CACHE, "w")))
66 + if(!(cache = fopen(getCacheFile(), "w")))
68 for(i = 0; i < count; i++) {
69 if(i > 0 && !strcmp(items[i], items[i-1]))
74 - if(stat(CACHE, &st) < 0)
75 + if(stat(getCacheFile(), &st) < 0)
78 if(!(p = strdup(path)))
87 + if (cachefile == NULL) {
89 + char cachepath[256];
91 + handle = xdgInitHandle(malloc(sizeof(xdgHandle)));
93 + strncpy(cachepath, xdgCacheHome(handle), 256);
94 + strcat(cachepath, CACHEDIR);
96 + int ret = xdgMakePath(cachepath, 0755);
97 + if (ret < 0 && errno != EEXIST) {
98 + perror("couldn't make path");
102 + strcat(cachepath, CACHEFILE);
104 + cachefile = malloc(strlen(cachepath) * sizeof(char));
105 + strncpy(cachefile, cachepath, strlen(cachepath));