dotfiles/.local/bin/mew-drun
2025-08-12 23:01:17 -06:00

28 lines
551 B
Bash
Executable file

#!/bin/sh
cache=""$HOME"/.cache/mew_drun"
dirs="$HOME/.local/share/applications/ /usr/share/applications/"
build_cache() {
find $dirs -type f -name "*.desktop" | \
xargs -n1 basename | \
sed 's/\.desktop$//' | \
sort -u > $cache
}
check_cache() {
[ -f "$cache" ] || build_cache
for d in $dirs; do
[ "$d" -nt "$cache" ] && return 0
done
find $dirs -type f -name '*.desktop' -newer "$cache" -print -quit | \
grep -q . && return 0
return 1
}
check_cache && build_cache
choice="$(mew < "$cache")"
gtk-launch $choice