X-Git-Url: https://git.xinqibao.xyz/dmenu.git/blobdiff_plain/53e92b5c1797ae5d259942b0a3f20a63c1a02f1e..153aaf88bf9bf5c6c4b118bd871f8cf1eafdcab5:/dmenu_path?ds=sidebyside

diff --git a/dmenu_path b/dmenu_path
old mode 100755
new mode 100644
index 3569077..3a7cda7
--- a/dmenu_path
+++ b/dmenu_path
@@ -1,26 +1,13 @@
-#!/bin/sh -f
-CACHE=$HOME/.dmenu_cache
-IFS=:
+#!/bin/sh
 
-qfind() {
-	find "$@" 2>/dev/null
-}
+cachedir="${XDG_CACHE_HOME:-"$HOME/.cache"}"
+cache="$cachedir/dmenu_run"
 
-uptodate() {                                                                       
-	test -f $CACHE &&
-		test "$(echo "$PATH")" = "$(sed 1q "$CACHE")" &&
-		! qfind $PATH -maxdepth 0 -newer $CACHE >/dev/null
-}
+[ ! -e "$cachedir" ] && mkdir -p "$cachedir"
 
-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
-	}
-	mv $CACHE.$pid $CACHE
+IFS=:
+if stest -dqr -n "$cache" $PATH; then
+	stest -flx $PATH | sort -u | tee "$cache"
+else
+	cat "$cache"
 fi
-
-tail -n +2 $CACHE
-