2018-02-05 21:31:56 -06:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
BAR_ICON=""
|
2018-06-30 20:43:00 -05:00
|
|
|
NOTIFY_ICON=/usr/share/icons/gnome/32x32/apps/system-software-update.png
|
2018-02-05 21:31:56 -06:00
|
|
|
|
2018-07-15 23:44:10 -05:00
|
|
|
get_total_updates() { UPDATES=$(checkupdates 2>/dev/null | wc -l); }
|
2018-05-12 13:00:19 -05:00
|
|
|
|
2018-02-05 21:31:56 -06:00
|
|
|
while true; do
|
2018-06-30 20:43:00 -05:00
|
|
|
get_total_updates
|
|
|
|
|
2018-07-19 20:52:19 -05:00
|
|
|
# notify user of updates
|
2018-02-05 21:31:56 -06:00
|
|
|
if hash notify-send &>/dev/null; then
|
2018-06-30 20:43:00 -05:00
|
|
|
if (( UPDATES > 50 )); then
|
2018-07-19 20:52:19 -05:00
|
|
|
notify-send -u critical -i $NOTIFY_ICON \
|
|
|
|
"You really need to update!!" "$UPDATES New packages"
|
2018-06-30 20:43:00 -05:00
|
|
|
elif (( UPDATES > 25 )); then
|
2018-07-19 20:52:19 -05:00
|
|
|
notify-send -u normal -i $NOTIFY_ICON \
|
|
|
|
"You should update soon" "$UPDATES New packages"
|
2018-06-30 20:43:00 -05:00
|
|
|
elif (( UPDATES > 2 )); then
|
2018-07-19 20:52:19 -05:00
|
|
|
notify-send -u low -i $NOTIFY_ICON \
|
|
|
|
"$UPDATES New packages"
|
2018-02-05 21:31:56 -06:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2018-07-19 20:52:19 -05:00
|
|
|
# when there are updates available
|
|
|
|
# every 10 seconds another check for updates is done
|
2018-06-30 20:43:00 -05:00
|
|
|
while (( UPDATES > 0 )); do
|
|
|
|
if (( UPDATES == 1 )); then
|
2018-07-19 20:52:19 -05:00
|
|
|
echo "$UPDATES Update"
|
2018-06-30 20:43:00 -05:00
|
|
|
elif (( UPDATES > 1 )); then
|
2018-07-19 20:52:19 -05:00
|
|
|
echo "$UPDATES Updates"
|
2018-07-01 01:43:16 -05:00
|
|
|
else
|
|
|
|
echo $BAR_ICON
|
2018-02-05 21:31:56 -06:00
|
|
|
fi
|
2018-05-12 13:00:19 -05:00
|
|
|
sleep 10
|
2018-06-30 20:43:00 -05:00
|
|
|
get_total_updates
|
2018-02-05 21:31:56 -06:00
|
|
|
done
|
|
|
|
|
2018-07-19 20:52:19 -05:00
|
|
|
# when no updates are available, use a longer loop, this saves on CPU
|
|
|
|
# and network uptime, only checking once every 30 min for new updates
|
2018-06-30 20:43:00 -05:00
|
|
|
while (( UPDATES == 0 )); do
|
2018-02-05 21:31:56 -06:00
|
|
|
echo $BAR_ICON
|
2018-05-12 13:00:19 -05:00
|
|
|
sleep 1800
|
2018-06-30 20:43:00 -05:00
|
|
|
get_total_updates
|
2018-02-05 21:31:56 -06:00
|
|
|
done
|
|
|
|
done
|