#!/usr/bin/env bash BAR_ICON="" NOTIFY_ICON=/usr/share/icons/gnome/32x32/apps/system-software-update.png get_total_updates() { UPDATES=$(checkupdates 2>/dev/null | wc -l); } while true; do get_total_updates # notify user with varying levels of urgency depending on amount of updates if hash notify-send &>/dev/null; then if (( UPDATES > 50 )); then notify-send -u critical -i $NOTIFY_ICON "You really need to update!!" "$UPD New packages" elif (( UPDATES > 25 )); then notify-send -u normal -i $NOTIFY_ICON "You should update soon" "$UPD New packages" elif (( UPDATES > 2 )); then notify-send -u low -i $NOTIFY_ICON "$UPD New packages" fi fi # loop while updates are greater than zero # during which every 10 seconds another check for fresh updates is done while (( UPDATES > 0 )); do if (( UPDATES == 1 )); then echo "$UPD Update" elif (( UPDATES > 1 )); then echo "$UPD Updates" else echo $BAR_ICON fi sleep 10 get_total_updates done # when no updates are available we go into a much longer loop to save cpu time # and only check once every 30 min for new updates while (( UPDATES == 0 )); do echo $BAR_ICON sleep 1800 get_total_updates done done