dotfiles/.local/scripts/status/0185_10_bat

46 lines
689 B
Bash
Executable File

#!/bin/bash
DEVICE="BAT0"
COLOR1="#FF00F4"
COLOR2="#83007D"
if [ ! -f "/sys/class/power_supply/$DEVICE/capacity" ]
then
echo "0185"
exit 1
fi
batpercent="$(cat /sys/class/power_supply/$DEVICE/capacity)"
if [ $batpercent -ge 80 ]
then
icon=""
elif [ $batpercent -ge 60 ]
then
icon=""
elif [ $batpercent -ge 40 ]
then
icon=""
elif [ $batpercent -ge 20 ]
then
icon=""
else
icon=""
fi
chrg="$(cat /sys/class/power_supply/$DEVICE/status)"
if [ "$chrg" = "Charging" ]
then
icon=""
elif [ "$chrg" = "Full" ]
then
icon=""
fi
batpercent="$(echo $batpercent)%"
echo "^b$COLOR1^^c$COLOR2^ $icon ^c$COLOR1^^b$COLOR2^ $batpercent ^d^"