#!/bin/sh

set -e

info="$(xbps-install -Mun)"
[ -z $info ] && exit

PKG_COUNT="$(echo -n "$info" | wc -l)"

DL_SIZE="$(echo "$info" | awk '{s+=$6}END{print s}' | numfmt --to=iec-i)B"

echo '{"text": "\uf468 '"$PKG_COUNT"'", "tooltip": "'"$PKG_COUNT"' packages have updates; '"$DL_SIZE"' download"}'
