get_updates_amount.sh 942 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env bash
  2. ###################################################
  3. # Shows available updates for Arch or Debian Linux.
  4. ###################################################
  5. get_updates_amount_debian() {
  6. # Get amount of updates for Debian Linux.
  7. amount_updates=$(apt-show-versions -u -b | wc -l)
  8. if [[ -z "$updates" ]]; then
  9. echo
  10. else
  11. echo " ${amount_updates}"
  12. fi
  13. }
  14. get_updates_amount_arch() {
  15. # Get amount of updates for Arch Linux.
  16. amount_updates=$(checkupdates-with-aur | wc -l)
  17. if [[ -z "${amount_updates}" ]] || [[ "${amount_updates}" -eq 0 ]]; then
  18. echo
  19. else
  20. echo " ${amount_updates}"
  21. fi
  22. }
  23. terminal="alacritty"
  24. distro=$(lsb_release -a 2>/dev/null | grep -i 'distributor id' | awk '{print $3}')
  25. case $distro in
  26. "Debian") get_updates_amount_debian;;
  27. "Arch"|"ManjaroLinux") get_updates_amount_arch;;
  28. *) notify-send -i dialog-error "Error:" "Unknown distro $distro.";;
  29. esac
  30. exit 0