logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git

dmenu_path (556B)


  1. #!/bin/sh
  2. # Port of suckless's dmenu_path(1) to pure POSIX
  3. cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"}
  4. if [ -d "$cachedir" ]; then
  5. cache=$cachedir/dmenu_run
  6. else
  7. cache=$HOME/.dmenu_cache # if no xdg dir, fall back to dotfile in ~
  8. fi
  9. test -f "${cache}" || touch -d 1970-01-01T00:00:00 "${cache}"
  10. IFS=:
  11. if [ "$(find "$PATH" -type d -newer "$cache" 2>/dev/null | wc -l)" != "0" ]; then
  12. find "$PATH" -type f -perm -o=rx 2>/dev/null | while read -r file; do basename "$file"; done | sort -u | tee "$cache"
  13. else
  14. cat "$cache"
  15. fi