#!/usr/bin/env bash
capacity=$(cat /sys/class/power_supply/BAT0/capacity) || break
time_left=$($HOME/.local/scripts/status/battery_time_left);
status=$(cat /sys/class/power_supply/BAT0/status)

if [[ $status == "Charging" ]]
then
    echo " $capacity% $time_left"
elif [[ $status == "Not charging" ]]
then
    echo " $capacity%"
else
    if [[ $capacity -ge 75 ]]
    then
        status=""
    elif [[ $capacity -ge 50 ]]
    then
        status=""
    elif [[ $capacity -ge 25 ]]
    then
        status=""
    elif [[ $capacity -ge 10 ]]
    then
        status=""
    elif [[ $capacity -gt 5 ]]
    then
        notify-send -u critical "Battery: Charge now!"
        status=""
    else
        notify-send -u critical "Battery: Critical (< 5%)!"
        status=""
    fi
    echo "$status $capacity% $time_left"
fi
