diff options
Diffstat (limited to 'wmenu_run')
-rwxr-xr-x | wmenu_run | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/wmenu_run b/wmenu_run new file mode 100755 index 0000000..b243b38 --- /dev/null +++ b/wmenu_run @@ -0,0 +1,35 @@ +#!/bin/sh + +cachedir="${XDG_CACHE_HOME:-"$HOME/.cache"}" +cache="$cachedir/wmenu_run" + +[ -d "$cachedir" ] || mkdir -p "$cachedir" + +uptodate() { + [ -f "$cache" ] || return 1 + IFS=: + for path in $PATH; do + # non-POSIX + test "$path" -nt "$cache" && return 1 + done + return 0 +} + +bins() { + IFS=: + for path in $PATH; do + for bin in "$path"/*; do + [ -x "$bin" ] && echo "${bin##*/}" + done + done +} + +path() { + if uptodate; then + cat "$cache" + else + bins | sort -u | tee "$cache" + fi +} + +path | wmenu "$@" | ${SHELL:-"/bin/sh"} & |