dotfiles/polybar/.config/polybar/scripts/poly-archupdates

31 lines
934 B
Bash
Executable File

#!/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, (pacman-contrib optional)
# 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
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_repo + updates_aur))"
if [ "$updates" -gt 0 ]; then
echo "$updates"
else
echo ""
fi