aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/wayland/.local/bin/wmenu-run
blob: fd1f669b906c27a2d39586033ce36f9e2038132e (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/wmenu-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