chore(waybar): improve custom pacman module

This commit is contained in:
2025-07-19 11:47:12 +02:00
parent 079779a52a
commit a91a9f34bf
2 changed files with 12 additions and 4 deletions

View File

@@ -1,7 +1,14 @@
#! /usr/bin/env bash
#!/usr/bin/env bash
main() {
checkupdates | wc -l
updates=$(checkupdates --nocolor 2>/dev/null)
if [[ $? -ne 0 || -z "$updates" ]]; then
echo '{"text": "", "tooltip": ""}' | jq --unbuffered --compact-output
else
numberOfUpdates=$(echo "$updates" | wc -l)
tooltip=$(echo "$updates" | sed 's/\n/\r/g' | jq -sR .)
echo "{\"text\": \"$numberOfUpdates\", \"tooltip\": $tooltip}" | jq --unbuffered --compact-output
fi
}
main $@
main "$@"