logo

utils

Old programs, got split in utils-std and utils-extra git clone https://anongit.hacktivis.me/git/utils.git/

dmenu_path (684B)


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