diff --git a/polybar/.config/polybar/scripts/poly-archupdates b/polybar/.config/polybar/scripts/poly-archupdates index b99a3ad..475a4ca 100755 --- a/polybar/.config/polybar/scripts/poly-archupdates +++ b/polybar/.config/polybar/scripts/poly-archupdates @@ -1,18 +1,27 @@ #!/bin/sh +# +# check for available archupdates and return their number +# checks both repositories and aur +# returns empty string when 0 packages are available, so +# that polybar simply displays nothing. +# +# dependendies: yay, bc, (pacman-contrib optional) -if ! updates_arch=$(yay -Qun 2>/dev/null | wc -l); then - updates_arch=0 +# prefer checkupdates since it allows checking w/o partial upgrade +if command -v "checkupdates" >/dev/null; then + updates_repo="$(checkupdates | wc -l)" +# fall back to yay, but be aware it will not find everything +else + updates_repo="$(yay -Qun 2>/dev/null | wc -l)" fi -if ! updates_aur=$(yay -Qum 2>/dev/null | wc -l); then - # if ! updates_aur=$(cower -u 2> /dev/null | wc -l); then - # if ! updates_aur=$(trizen -Su --aur --quiet | wc -l); then - # if ! updates_aur=$(pikaur -Qua 2> /dev/null | wc -l); then - # if ! updates_aur=$(rua upgrade --printonly 2> /dev/null | wc -l); then - updates_aur=0 -fi +updates_aur="$(yay -Qum 2>/dev/null | wc -l)" +# if ! updates_aur=$(cower -u 2> /dev/null | wc -l); then +# if ! updates_aur=$(trizen -Su --aur --quiet | wc -l); then +# if ! updates_aur=$(pikaur -Qua 2> /dev/null | wc -l); then +# if ! updates_aur=$(rua upgrade --printonly 2> /dev/null | wc -l); then -updates=$(("$updates_arch" + "$updates_aur")) +updates="$(echo "$updates_repo + $updates_aur" | bc)" if [ "$updates" -gt 0 ]; then echo "$updates"