Include .desktop path in app listings.

Slightly faster lookups, but mostly to disambiguate between apps with identical names.
This commit is contained in:
Sage Vaillancourt 2024-07-09 21:30:40 -04:00
parent ccf3caee81
commit 5df78e6c8a
1 changed files with 13 additions and 15 deletions

View File

@ -54,18 +54,22 @@ windows() {
fi fi
} }
function read_app {
echo "app $(grep '^Name=' "$1" | grep -Eiv "$IGNORED_APPS" | sed 's/Name=//' | head -n 1) <= $1"
}
read_apps() { read_apps() {
export -f read_app
export APP_LOCATIONS
export IGNORED_APPS
if [[ "$1" == "--now" ]]; then if [[ "$1" == "--now" ]]; then
find $APP_LOCATIONS -name '*.desktop' -exec grep '^Name=' {} \; | # shellcheck disable=SC2086
egrep -iv "$IGNORED_APPS" | find $APP_LOCATIONS -name '*.desktop' -exec bash -c 'read_app "{}"' \;
sed 's/Name=/app /'
return $? return $?
fi fi
cat "$CACHE_FILE" cat "$CACHE_FILE"
# shellcheck disable=SC2086 nohup find $APP_LOCATIONS -name '*.desktop' -exec bash -c 'read_app "{}"' \;
nohup find $APP_LOCATIONS -name '*.desktop' -exec grep '^Name=' {} \; |
egrep -iv "$IGNORED_APPS" |
sed 's/Name=/app /' > "$CACHE_FILE" &
} }
read_snap_apps() { read_snap_apps() {
@ -95,14 +99,8 @@ add-recent() {
} }
open_app() { open_app() {
app="$(echo "$1" | cut -c 5-)" desktop_file="$(echo "$1" | sed 's/app .*<= *//')"
# shellcheck disable=SC2086 setsid exo-open "$desktop_file" >/dev/null 2>&1 </dev/null &
find $APP_LOCATIONS -name '*.desktop' | while read -r f; do
if grep "Name=$app" "$f" &> /dev/null; then
setsid exo-open "$f" >/dev/null 2>&1 </dev/null &
return
fi
done
} }
list_files() { list_files() {