make tmenu_run faster by having an application name cache

This commit is contained in:
randomuser 2023-01-31 11:26:27 -06:00
parent a22c5fa20c
commit 38a242c999
2 changed files with 9 additions and 2 deletions

View File

@ -36,6 +36,7 @@ sh:
cp -f sh/git-credential-gitpass $(DESTDIR)$(PREFIX)/bin
cp -f sh/capture $(DESTDIR)$(PREFIX)/bin
cp -f sh/toggle-contingency-mode $(DESTDIR)$(PREFIX)/bin
ln -sf $(DESTDIR)$(PREFIX)/bin/tmenu_run $(DESTDIR)$(PREFIX)/bin/regenerate
check:
shellcheck sh/*

View File

@ -4,9 +4,15 @@ tmenu_path () {
IFS=" :"
for i in $PATH; do
for j in "$i"/*; do
[ -f "$j" ] && [ -x "$j" ] && printf "%s\n" "$j"
[ -f "$j" ] && [ -x "$j" ] && printf "%s\n" "$j" | xargs basename
done
done
}
tmenu_path | tmenu | ${SHELL:-"/bin/sh"} &
if [ "$1" = "-g" ] || [ "$(basename $0)" = "regenerate" ]; then
mkdir -p $HOME/.local/share
tmenu_path > $HOME/.local/share/tmenu_cache
xmessage "regeneration complete"
else
cat $HOME/.local/share/tmenu_cache | tmenu | ${SHELL:-"/bin/sh"} &
fi