46 lines
1.5 KiB
Bash
Executable File
46 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
BAR_ICON=""
|
|
NOTIFY_ICON=/usr/share/icons/gnome/32x32/apps/system-software-update.png
|
|
|
|
get_total_updates() { UPDATES=$(checkupdates | wc -l); }
|
|
|
|
while true; do
|
|
# we don't want to check for updates for liveuser, after we want to remove this
|
|
[[ $(whoami) == "liveuser" ]] && { sleep 2000; continue; } || sed '/liveuser/d' $HOME/bin/updates.sh
|
|
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
|