#!/bin/sh askupgrade() { [ "$(notify-send -c updates --action=Yes=Yes --action=No=No " Repository Sync" "Updates available. Update now?")" = 'Yes' ] && $TERMINAL -e upgrades } if command -v apt 1>/dev/null 2>&1; then n=$(sudo apt upgrade -dy 2>/dev/null | grep -m1 '^[0-9]\+ upgraded,' | tr -cd '0-9' | cut -c1-2) if [ "$n" = '' ]; then 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 askupgrade fi 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)" if [ "$n" != "0" ] && [ "$ne" != "0" ]; then notify-send -u critical "Error downloading updates." "$(cut -d " " -f 1,5 /tmp/xbps_errors)" elif [ "$n" -gt 1 ] && [ "$ne" = "0" ]; then askupgrade fi fi