dmenu_path (684B)
- #!/bin/sh
- # SPDX-FileCopyrightText: 2017-2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
- # SPDX-License-Identifier: MPL-2.0
- # Port of suckless's dmenu_path(1) to pure POSIX
- 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
- test -f "${cache}" || touch -d 1970-01-01T00:00:00 "${cache}"
- IFS=:
- if [ "$(find "$PATH" -type d -newer "$cache" 2>/dev/null | wc -l)" != "0" ]; then
- find "$PATH" -type f -perm -o=rx 2>/dev/null | while read -r file; do basename "$file"; done | sort -u | tee "$cache"
- else
- cat "$cache"
- fi