aboutsummaryrefslogtreecommitdiffstats
path: root/sway-launcher-desktop.sh
diff options
context:
space:
mode:
authorMoritz Meißelbach <m.meisselbach@inpsyde.com>2019-10-15 14:09:05 +0200
committerMoritz Meißelbach <m.meisselbach@inpsyde.com>2019-10-15 14:09:05 +0200
commit5cd4648cbb060b9f131619e4a1a8c4ad859bf37f (patch)
treea54f4864be27d3fb27d11c8979c8ee08122429f1 /sway-launcher-desktop.sh
parent6badc8ab9645783dabcb64e8cd6756e7c77311cd (diff)
downloadsway-launcher-desktop-5cd4648cbb060b9f131619e4a1a8c4ad859bf37f.tar.gz
sway-launcher-desktop-5cd4648cbb060b9f131619e4a1a8c4ad859bf37f.zip
Improve awk usage so only the first Name= entry is used from a desktop file
Diffstat (limited to 'sway-launcher-desktop.sh')
-rwxr-xr-xsway-launcher-desktop.sh7
1 files 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