blob: 318e54d78be06e39a38670629307daf82af13a91 (
plain)
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
|
#!/bin/sh
cache_dir="${XDG_CACHE_HOME:-"$HOME/.cache"}"
cache="$cache_dir/sway-menu-run"
uptodate() {
IFS=:
for path in $PATH; do
if test "$path" -nt "$cache"; then
return 1
fi
done
return 0
}
get_bin() {
IFS=:
for path in $PATH; do
for bin in "$path"/*; do
if [ -x "$bin" ]; then
echo "${bin##*/}"
fi
done
done
}
[ ! -e "$cache_dir" ] && mkdir -p "$cache_dir"
if [ ! -e "$cache" ] || ! uptodate; then
get_bin | sort -u | tee "$cache" | sway-menu
else
cat "$cache"
fi
|