Add color for battery.

This commit is contained in:
Tom Alexander 2022-11-12 12:52:26 -05:00
parent e60ca1a4e4
commit 9dda4875c0
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 23 additions and 4 deletions

View File

@ -76,11 +76,11 @@
animation-direction: alternate;
}
#battery.warning {
#custom-battery.warning {
color: orange;
}
#battery.critical {
#custom-battery.critical {
color: red;
}

View File

@ -13,6 +13,7 @@ while true; do
battery_percentage=$(apm -l)
battery_status=$(apm -b)
seconds_remaining=$(apm -t)
class=""
if [ $battery_status -eq 3 ]; then
if [ $battery_percentage -eq 100 ]; then
@ -33,6 +34,13 @@ while true; do
else
battery_icon=""
fi
if [ $battery_percentage -le 15 ]; then
class="critical"
elif [ $battery_percentage -le 30 ]; then
class="warning"
fi
if [ $seconds_remaining -eq -1 ]; then
time_remaining="unknown time remaining."
else
@ -43,7 +51,8 @@ while true; do
{
"text":"${battery_percentage}% ${battery_icon}",
"tooltip":"${time_remaining}",
"percentage":${battery_percentage}
"percentage":${battery_percentage},
"class":"${class}"
}
EOF
sleep $SLEEP_INTERVAL

View File

@ -13,6 +13,8 @@ while true; do
text=""
tooltip=""
percentage=""
class=""
while read bat; do
battery_now=$(cat "$bat/charge_now")
battery_capacity=$(cat "$bat/charge_full")
@ -39,6 +41,13 @@ while true; do
else
battery_icon=""
fi
if [ $battery_percentage -le 15 ]; then
class="critical"
elif [ $battery_percentage -le 30 ]; then
class="warning"
fi
if [ $seconds_remaining -eq -1 ]; then
time_remaining="unknown time remaining."
else
@ -55,7 +64,8 @@ while true; do
{
"text":"$text",
"tooltip":"$tooltip",
"percentage":$percentage
"percentage":${percentage},
"class":"${class}"
}
EOF
sleep $SLEEP_INTERVAL