#!/bin/bash
#  ▓▓▓▓▓▓▓▓▓▓ 
# ░▓ Author ▓ Abdullah <https://abdullah.today/> 
# ░▓▓▓▓▓▓▓▓▓▓ 
# ░░░░░░░░░░ 

# If battery is low, push a notification

battery_status=$(cat /sys/class/power_supply/BAT0/capacity)
is_charger_connected=$(cat /sys/class/power_supply/AC/online)


while true; do
  if (( "$( < /sys/class/power_supply/BAT0/capacity )" < 30 )); then
    notify-send -u critical "Battery critically low"
  elif (( "$( < /sys/class/power_supply/BAT0/capacity )" < 15 )); then
    notify-send -u critical "Hibernating the system. Bye!" && systemctl hibernate
  fi
  sleep 600
done
