From 5cd4648cbb060b9f131619e4a1a8c4ad859bf37f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20Mei=C3=9Felbach?= Date: Tue, 15 Oct 2019 14:09:05 +0200 Subject: Improve awk usage so only the first Name= entry is used from a desktop file --- sway-launcher-desktop.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sway-launcher-desktop.sh b/sway-launcher-desktop.sh index 3e91540..8043423 100755 --- a/sway-launcher-desktop.sh +++ b/sway-launcher-desktop.sh @@ -11,6 +11,7 @@ if [[ "$1" = 'describe' ]]; then description="${arr[0]}" description="${description%*-}" else + echo $1 title=$(sed -ne '/^Name=/{s/^Name=//;p;q}' "$1") description=$(sed -ne '/^Comment=/{s/^Comment=//;p;q}' "$1") fi @@ -44,9 +45,9 @@ trap 'rm "$FZFPIPE" "$PIDFILE"' EXIT INT for dir in "${DIRS[@]}"; do [[ -d "$dir" ]] || continue awk -v pre="$GLYPH_DESKTOP" -F= ' - BEGINFILE{p=0;} - /^Type=Application/{p=1;} - /^Name=/{name=$2;} + BEGINFILE{p=0;n=0} + /^Type=Application/{p=1} + /^Name=/{if(!n) {n=1;name=$2;}} ENDFILE{if (p) print FILENAME "|desktop|\033[33m" pre name "\033[0m";}' \ "$dir/"*.desktop < /dev/null >> "$FZFPIPE" # the empty stdin is needed in case no *.desktop files -- cgit v1.2.3