blob: b243b38acadafded6dbf62e6409b7ec85a16351f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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"} &
|