mew

dmenu for wayland
git clone https://git.awy.one/mew
Log | Files | Refs | README | LICENSE

mew-run (499B) - View raw


 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/mew_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 | mew -e "$@"