X-Git-Url: https://git.armaanb.net/?a=blobdiff_plain;f=dmenu_path;h=338bac47cd36f60a148a8b0759164f54e1035a0d;hb=5ed5e90bfb7760f24661281cf7156087afbe49d3;hp=94db694cbb7c049dc5ce2e23e539843f467a0f4d;hpb=d50ff5ca11564237f4f3f4a3b2d28f282c787acf;p=dmenu.git diff --git a/dmenu_path b/dmenu_path old mode 100755 new mode 100644 index 94db694..338bac4 --- a/dmenu_path +++ b/dmenu_path @@ -1,26 +1,13 @@ -#!/bin/sh -f -CACHE=$HOME/.dmenu_cache +#!/bin/sh +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=: - -qfind() { - find "$@" 2>/dev/null -} - -uptodate() { - test -f $CACHE && - test "$(echo "$PATH")" = "$(sed 1q "$CACHE")" && - qfind $PATH -maxdepth 0 -newer $CACHE >/dev/null -} - -if ! uptodate -then - { - echo "$PATH" - qfind $PATH -type f -maxdepth 1 '(' -perm -u+x -o -perm -g+x -o -perm -o+x ')' | - sed 's,.*/,,' | sort | uniq - } > $CACHE.$pid - mv $CACHE.$pid $CACHE +if stest -dqr -n "$cache" $PATH; then + stest -flx $PATH | sort -u | tee "$cache" +else + cat "$cache" fi - -tail -n +2 $CACHE -