[polybar] Add safer package update checking
Package updates in yay (as in pacman) will not be reported correctly when the repository mirrors have not been updated recently. However, updating only the mirrors without also synching the packages locally is not recommended by arch. That means, essentially, we can't do a dry-run to only 'check' for packages without running the danger of performing a partial arch upgrade. The program `checkupdates` in pacman-contrib package helps with this by performing a check for the available updates without needing to pull from the mirrors before. So, the polybar update script now checks for its existence and uses it if available, falling back to the standard yay procedure otherwise.
This commit is contained in:
parent
3f1443c546
commit
f0dff67410
1 changed files with 19 additions and 10 deletions
|
@ -1,18 +1,27 @@
|
||||||
#!/bin/sh
|
#!/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
|
# prefer checkupdates since it allows checking w/o partial upgrade
|
||||||
updates_arch=0
|
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
|
fi
|
||||||
|
|
||||||
if ! updates_aur=$(yay -Qum 2>/dev/null | wc -l); then
|
updates_aur="$(yay -Qum 2>/dev/null | wc -l)"
|
||||||
# if ! updates_aur=$(cower -u 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=$(trizen -Su --aur --quiet | wc -l); then
|
||||||
# if ! updates_aur=$(pikaur -Qua 2> /dev/null | 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
|
# if ! updates_aur=$(rua upgrade --printonly 2> /dev/null | wc -l); then
|
||||||
updates_aur=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
updates=$(("$updates_arch" + "$updates_aur"))
|
updates="$(echo "$updates_repo + $updates_aur" | bc)"
|
||||||
|
|
||||||
if [ "$updates" -gt 0 ]; then
|
if [ "$updates" -gt 0 ]; then
|
||||||
echo "$updates"
|
echo "$updates"
|
||||||
|
|
Loading…
Reference in a new issue