#!/bin/sh

updates_arch=$(checkupdates 2> /dev/null | wc -l );
[ -z "$updates_arch" ] && updates_arch=0

updates_aur=$(checkupdates-aur 2> /dev/null | wc -l)
[ -z "$updates_aur" ] && updates_aur=0

updates=$((updates_arch + updates_aur))

if [ "$1" = "Up" ]; then
	echo "Updates available for $updates Packages"
	sleep 1
	echo "Updating..."
	yay -Syu && echo "Updated Successfully" || echo "Failed"
	echo "press <Enter> to exit"
	read -r _

else
	echo "$updates"
fi

