2022-07-04 21:36:33 +02:00
#!/bin/sh
2023-02-20 12:23:39 +01:00
askupgrade() {
[ "$(notify-send -c updates --action=Yes=Yes --action=No=No " Repository Sync" "Updates available. Update now?")" = 'Yes' ] && $TERMINAL -e upgrades
}
2022-07-04 21:36:33 +02:00
2023-06-15 11:47:56 +02:00
if command -v apt 1>/dev/null 2>&1; then
2023-02-16 18:59:33 +01:00
n=$(sudo apt upgrade -dy 2>/dev/null | grep -m1 '^[0-9]\+ upgraded,' | tr -cd '0-9' | cut -c1-2)
if [ "$n" = '' ]; then
2023-11-24 15:46:14 +01:00
notify-send -u critical "Error downloading updates." "Check your internet connection, if apt is already running, or run update manually to see errors."
elif [ "$n" != 00 ]; then
2023-02-20 12:23:39 +01:00
askupgrade
2023-02-16 18:59:33 +01:00
fi
2023-05-25 18:58:01 +02:00
elif command -v xbps-install 1>/dev/null 2>&1; then
xbps-install -nuM 1>/tmp/xbps_updates 2>/tmp/xbps_errors
n="$(wc -l < /tmp/xbps_updates)"
ne="$(grep broken /tmp/xbps_errors | wc -l)"
n="$(xbps-install -M -n -u | grep -Fe update -e install | wc -l)"
2023-11-24 15:46:14 +01:00
if [ "$n" != "0" ] && [ "$ne" != "0" ]; then
notify-send -u critical "Error downloading updates." "$(cut -d " " -f 1,5 /tmp/xbps_errors)"
2023-05-25 18:58:01 +02:00
elif [ "$n" -gt 1 ] && [ "$ne" = "0" ]; then
askupgrade
fi
2022-07-04 21:36:33 +02:00
fi