2022-09-17 11:55:17 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-03-02 17:37:56 +08:00
|
|
|
DEVICE="BAT0"
|
2022-10-01 14:45:43 +08:00
|
|
|
|
2022-09-17 11:55:17 +08:00
|
|
|
COLOR1="#FF00F4"
|
|
|
|
COLOR2="#83007D"
|
|
|
|
|
|
|
|
|
2023-03-02 17:37:56 +08:00
|
|
|
if [ ! -f "/sys/class/power_supply/$DEVICE/capacity" ]
|
2022-10-01 14:45:43 +08:00
|
|
|
then
|
2023-03-02 17:37:56 +08:00
|
|
|
echo "0185"
|
|
|
|
exit 1
|
2022-10-01 14:45:43 +08:00
|
|
|
fi
|
|
|
|
|
2022-09-17 11:55:17 +08:00
|
|
|
batpercent="$(cat /sys/class/power_supply/$DEVICE/capacity)"
|
|
|
|
|
2023-03-02 17:37:56 +08:00
|
|
|
if [ $batpercent -ge 80 ]
|
2022-09-17 11:55:17 +08:00
|
|
|
then
|
|
|
|
icon=""
|
2023-03-02 17:37:56 +08:00
|
|
|
elif [ $batpercent -ge 60 ]
|
2022-09-17 11:55:17 +08:00
|
|
|
then
|
|
|
|
icon=""
|
2023-03-02 17:37:56 +08:00
|
|
|
elif [ $batpercent -ge 40 ]
|
2022-09-17 11:55:17 +08:00
|
|
|
then
|
|
|
|
icon=""
|
2023-03-02 17:37:56 +08:00
|
|
|
elif [ $batpercent -ge 20 ]
|
2022-09-17 11:55:17 +08:00
|
|
|
then
|
|
|
|
icon=""
|
|
|
|
else
|
|
|
|
icon=""
|
|
|
|
fi
|
|
|
|
|
2023-03-02 17:37:56 +08:00
|
|
|
chrg="$(cat /sys/class/power_supply/$DEVICE/status)"
|
2022-09-28 09:48:53 +08:00
|
|
|
|
2023-03-02 17:37:56 +08:00
|
|
|
if [ "$chrg" = "Charging" ]
|
2022-09-28 09:48:53 +08:00
|
|
|
then
|
|
|
|
icon=""
|
2023-03-02 17:37:56 +08:00
|
|
|
elif [ "$chrg" = "Full" ]
|
2022-09-28 09:48:53 +08:00
|
|
|
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^"
|