#!/usr/bin/env bash

if [ ! -f /etc/arch-release ]; then
  exit 0
fi

AUR=$(paru -Qua | wc -l)
OFFICIAL=$(checkupdates | wc -l)

case $1 in
  aur) echo " $AUR";;
  official) echo " $OFFICIAL";;
esac

if [ "$1" = "update" ]; then
  alacritty -o 'window.startup_mode="Fullscreen"' -e 'paru'
fi

if [ "$1" = "json" ]; then
  COUNT=$((OFFICIAL+AUR))

  echo "{ \"text\": \" $COUNT\", \"alt\": \"$COUNT Updates\", \"tooltip\": \"Updates Available\n\nAUR: $AUR\nOfficial: $OFFICIAL\nTotal: $COUNT\" }"
fi

if [ "$1" = "" ]; then
  echo " $((OFFICIAL+AUR))"
fi
