refactor(waybar): do not return package updates if none are available

This commit is contained in:
Price Hiller 2023-06-05 02:58:36 -05:00
parent bf608fc2b5
commit 4e9b87ae1a
Signed by: Price
SSH Key Fingerprint: SHA256:Y4S9ZzYphRn1W1kbJerJFO6GGsfu9O70VaBSxJO7dF8

View File

@ -9,9 +9,11 @@ main() {
if ((package_update_number > 10)); then
package_updates="$(printf "%s" "${package_updates}" | head -n 10)"
package_updates+="\n..."
elif (( package_update_number == 0 )); then
# Don't return anything if there are no updates available
return 0
fi
printf '{"text": "%s", "tooltip": "%s"}\n' "${package_update_number}" "${package_updates//$'\n'/\\n}"
}