static char text[BUFSIZ] = "";
static int bh, mw, mh;
static int inputw, promptw;
-static int lines = 0;
static size_t cursor = 0;
static const char *font = NULL;
static const char *prompt = NULL;
static const char *normfgcolor = "#000000";
static const char *selbgcolor = "#0066ff";
static const char *selfgcolor = "#ffffff";
+static unsigned int lines = 0;
static unsigned long normcol[ColLast];
static unsigned long selcol[ColLast];
static Atom utf8;
#!/bin/sh
CACHE=${XDG_CACHE_HOME:-"$HOME/.cache"}/dmenu_run
+if [ ! -d "`dirname "$CACHE"`" ]; then
+ CACHE=$HOME/.dmenu_cache
+fi
(
IFS=:
if test "`ls -dt $PATH "$CACHE" 2> /dev/null | sed 1q`" != "$CACHE"; then
- mkdir -p "`dirname "$CACHE"`" && lsx $PATH | sort -u > "$CACHE"
+ lsx $PATH | sort -u > "$CACHE"
fi
)
cmd=`dmenu "$@" < "$CACHE"` && exec sh -c "$cmd"
/* See LICENSE file for copyright and license details. */
#include <dirent.h>
+#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
static void lsx(const char *dir);
+static int status = EXIT_SUCCESS;
+
int
main(int argc, char *argv[]) {
int i;
lsx(".");
else for(i = 1; i < argc; i++)
lsx(argv[i]);
- return EXIT_SUCCESS;
+ return status;
}
void
struct stat st;
DIR *dp;
- if(!(dp = opendir(dir))) {
- perror(dir);
- return;
- }
- while((d = readdir(dp)))
+ for(dp = opendir(dir); dp && (d = readdir(dp)); errno = 0)
if(snprintf(buf, sizeof buf, "%s/%s", dir, d->d_name) < (int)sizeof buf
- && !stat(buf, &st) && S_ISREG(st.st_mode) && access(buf, X_OK) == 0)
+ && access(buf, X_OK) == 0 && stat(buf, &st) == 0 && S_ISREG(st.st_mode))
puts(d->d_name);
- closedir(dp);
+
+ if(errno != 0) {
+ status = EXIT_FAILURE;
+ perror(dir);
+ }
+ if(dp)
+ closedir(dp);
}