Archlinux basic installation configuration scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.3 KiB

  1. #!/usr/bin/env bash
  2. NOTIFY_ICON=/usr/share/icons/Papirus/32x32/apps/system-software-update.svg
  3. get_total_updates() { UPDATES=$(checkupdates 2>/dev/null | wc -l); }
  4. while true; do
  5. get_total_updates
  6. # notify user of updates
  7. if hash notify-send &>/dev/null; then
  8. if (( UPDATES > 50 )); then
  9. notify-send -u critical -i $NOTIFY_ICON \
  10. "You really need to update!!" "$UPDATES New packages"
  11. elif (( UPDATES > 25 )); then
  12. notify-send -u normal -i $NOTIFY_ICON \
  13. "You should update soon" "$UPDATES New packages"
  14. elif (( UPDATES > 2 )); then
  15. notify-send -u low -i $NOTIFY_ICON \
  16. "$UPDATES New packages"
  17. fi
  18. fi
  19. # when there are updates available
  20. # every 10 seconds another check for updates is done
  21. while (( UPDATES > 0 )); do
  22. if (( UPDATES == 1 )); then
  23. echo " $UPDATES"
  24. elif (( UPDATES > 1 )); then
  25. echo " $UPDATES"
  26. else
  27. echo " None"
  28. fi
  29. sleep 10
  30. get_total_updates
  31. done
  32. # when no updates are available, use a longer loop, this saves on CPU
  33. # and network uptime, only checking once every 30 min for new updates
  34. while (( UPDATES == 0 )); do
  35. echo " None"
  36. sleep 1800
  37. get_total_updates
  38. done
  39. done