]> git.armaanb.net Git - dmenu.git/blobdiff - dmenu_path
Switch to dark theme
[dmenu.git] / dmenu_path
index a9a89b73cc51a0bba3b46ee6a6f8fb04f72688f1..3a7cda79273778642accd4221aa6f1419a1f221d 100755 (executable)
@@ -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
-}
+[ ! -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
-       } > $CACHE.$pid
-       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
-