#!/usr/bin/env bash

while [ 1 ]; 
do
    capacity=$(cat /sys/class/power_supply/BAT1/capacity)
    status=$(cat /sys/class/power_supply/BAT1/status)

    if [ $status = 'Charging' ]; then
        eww close battery
        sleep 10
    else
        if [ $capacity -le 30  ];
        then
            eww open battery
        else
            eww close battery
        fi
        sleep 10
    fi
done
