diff options
Diffstat (limited to 'dmenu_run')
-rwxr-xr-x | dmenu_run | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -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"} & |