polybar: Fix archupdate display
Fixed archupdates to work even if `checkupdates` script returns an error by falling back to `yay` to do its package update detection.
This commit is contained in:
parent
3bf5becbe2
commit
8234fdfdf0
1 changed files with 20 additions and 13 deletions
|
@ -6,24 +6,31 @@
|
||||||
# that polybar simply displays nothing.
|
# that polybar simply displays nothing.
|
||||||
#
|
#
|
||||||
# dependendies: yay, (pacman-contrib optional)
|
# dependendies: yay, (pacman-contrib optional)
|
||||||
|
#
|
||||||
|
# Takes an optional integer argument, which is the minimum
|
||||||
|
# numer of package updates for an answer to be returned.
|
||||||
|
min_upd=${1:-0}
|
||||||
|
|
||||||
# prefer checkupdates since it allows checking w/o partial upgrade
|
# prefer checkupdates since it allows checking w/o partial upgrade
|
||||||
if command -v "checkupdates" >/dev/null; then
|
if command -v "checkupdates" >/dev/null; then
|
||||||
updates_repo="$(checkupdates | wc -l)"
|
updates_repo="$(checkupdates 2>&1)"
|
||||||
# fall back to yay, but be aware it will not find everything
|
|
||||||
else
|
|
||||||
updates_repo="$(yay -Qun 2>/dev/null | wc -l)"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# fall back to yay, but be aware it will not find everything
|
||||||
|
# if checkupdates finds nothing or returns an error
|
||||||
|
if [ "$updates_repo" = "" ] || [ -z "${updates_repo##*==> ERROR: Cannot fetch updates*}" ]; then
|
||||||
|
updates_repo="$(yay -Qun 2>/dev/null)"
|
||||||
|
fi
|
||||||
|
updates_repo=$(echo "$updates_repo" | wc -l)
|
||||||
|
|
||||||
updates_aur="$(yay -Qum 2>/dev/null | wc -l)"
|
updates_aur="$(yay -Qum 2>/dev/null | wc -l)"
|
||||||
# if ! updates_aur=$(cower -u 2> /dev/null | wc -l); then
|
# updates_aur=$(cower -u 2> /dev/null | wc -l)
|
||||||
# if ! updates_aur=$(trizen -Su --aur --quiet | wc -l); then
|
# updates_aur=$(trizen -Su --aur --quiet | wc -l)
|
||||||
# if ! updates_aur=$(pikaur -Qua 2> /dev/null | wc -l); then
|
# updates_aur=$(pikaur -Qua 2> /dev/null | wc -l)
|
||||||
# if ! updates_aur=$(rua upgrade --printonly 2> /dev/null | wc -l); then
|
# updates_aur=$(rua upgrade --printonly 2> /dev/null | wc -l)
|
||||||
|
|
||||||
updates="$((updates_repo + updates_aur))"
|
updates=$((updates_repo + updates_aur))
|
||||||
|
if [ "$updates" -gt "$min_upd" ]; then
|
||||||
if [ "$updates" -gt 0 ]; then
|
|
||||||
echo "$updates"
|
echo "$updates"
|
||||||
else
|
else
|
||||||
echo ""
|
echo ""
|
||||||
|
|
Loading…
Reference in a new issue