## See https://github.com/OpenGamingCollective/asusctl/blob/main/distro-packaging/asusctl.install

_test_features() {
  platform_profile_choices="$(cat /sys/firmware/acpi/platform_profile_choices)"

  if [[ $platform_profile_choices != "quiet balanced performance" ]]; then
    if [[ $platform_profile_choices != "low-power balanced performance" ]]; then
      echo -e "\033[0;31m"
      echo "-> Platform profile support not found in current running kernel"
      echo "-> Make sure you are using a supported kernel: https://github.com/OpenGamingCollective/asusctl#kernel-support/"
      echo "-> and asus_wmi driver is loaded"
      echo -e "\033[0m"
    fi
  fi
}

post_install() {
  echo -e "\033[0;34m"
  echo "-> Enabling asusd service"
  echo -e "\033[0m"
  systemctl enable --now asusd.service

  _test_features
}

post_upgrade() {
  if systemctl is-active asusd.service --quiet
    then
      echo -e "\033[0;34m"
      printf "-> Restarting asusd service"
      echo -e "\033[0m"
      systemctl restart asusd.service
  fi

  _test_features
}

pre_remove() {
  systemctl disable --now asusd.service
}
