dotfiles/.local/scripts/status/0185_10_bat

45 lines
731 B
Plaintext
Raw Normal View History

2022-09-17 11:55:17 +08:00
#!/bin/bash
2022-10-01 14:45:43 +08:00
DEVICE="BAT1"
2022-09-17 11:55:17 +08:00
COLOR1="#FF00F4"
COLOR2="#83007D"
2022-10-01 14:45:43 +08:00
if [ ! -f "$FILE" ]
then
DEVICE="$(ls /sys/class/power_supply/ -1 -t | head -1)"
fi
2022-09-17 11:55:17 +08:00
batpercent="$(cat /sys/class/power_supply/$DEVICE/capacity)"
if [[ $((batpercent + 0)) -ge 80 ]]
then
icon=""
elif [[ $((batpercent + 0)) -ge 60 ]]
then
icon=""
elif [[ $((batpercent + 0)) -ge 40 ]]
then
icon=""
elif [[ $((batpercent + 0)) -ge 20 ]]
then
icon=""
else
icon=""
fi
2022-09-28 09:48:53 +08:00
chrg=$(cat /sys/class/power_supply/$DEVICE/status)
if [[ "$chrg" == "Charging" ]]
then
icon=""
elif [[ "$chrg" == "Full" ]]
then
icon=""
fi
2022-09-17 11:55:17 +08:00
batpercent="$(echo $batpercent)%"
echo "^b$COLOR1^^c$COLOR2^ $icon ^c$COLOR1^^b$COLOR2^ $batpercent ^d^"