aboutsummaryrefslogtreecommitdiff
path: root/dmenu_run
diff options
context:
space:
mode:
Diffstat (limited to 'dmenu_run')
-rwxr-xr-xdmenu_run17
1 files changed, 10 insertions, 7 deletions
diff --git a/dmenu_run b/dmenu_run
index e0a3e13..052e51b 100755
--- a/dmenu_run
+++ b/dmenu_run
@@ -1,12 +1,15 @@
#!/bin/sh
-CACHE=${XDG_CACHE_HOME:-"$HOME/.cache"}/dmenu_run
-if [ ! -d "`dirname "$CACHE"`" ]; then
- CACHE=$HOME/.dmenu_cache
+cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"}
+if [ -d "$cachedir" ]; then
+ cache=$cachedir/dmenu_run
+else
+ cache=$HOME/.dmenu_cache # if no xdg dir, fall back to dotfile in ~
fi
(
IFS=:
- if stest -dqr -n "$CACHE" $PATH; then
- stest -flx $PATH | sort -u > "$CACHE"
+ if stest -dqr -n "$cache" $PATH; then
+ stest -flx $PATH | sort -u | tee "$cache" | dmenu "$@"
+ else
+ dmenu "$@" < "$cache"
fi
-)
-cmd=`dmenu "$@" < "$CACHE"` && exec sh -c "$cmd"
+) | ${SHELL:-"/bin/sh"} &