improved battery status stuff

This commit is contained in:
Rudis Muiznieks 2022-06-24 12:27:46 -05:00
parent dbd4439f81
commit 335d15d24f
Signed by: rudism
GPG Key ID: CABF2F86EF7884F9
1 changed files with 35 additions and 10 deletions

View File

@ -118,6 +118,33 @@ append_percent_icon() {
segment_text="$segment_text$bgend%{O5}" segment_text="$segment_text$bgend%{O5}"
} }
append_battery_icon() {
local pct=$1
segment_text="$segment_text$bglight"
if (( pct < 10 )); then
segment_text="$segment_text"
elif (( pct < 20 )); then
segment_text="$segment_text"
elif (( pct < 30 )); then
segment_text="$segment_text"
elif (( pct < 40 )); then
segment_text="$segment_text"
elif (( pct < 50 )); then
segment_text="$segment_text"
elif (( pct < 60 )); then
segment_text="$segment_text"
elif (( pct < 70 )); then
segment_text="$segment_text"
elif (( pct < 80 )); then
segment_text="$segment_text"
elif (( pct < 90 )); then
segment_text="$segment_text"
else
segment_text="$segment_text"
fi
segment_text="$segment_text$bgend%{O5}"
}
segment_tags() { segment_tags() {
local monitor=$1 local monitor=$1
local tags local tags
@ -340,8 +367,6 @@ segment_battery() {
# battery status (charging/charged/etc) # battery status (charging/charged/etc)
batstat="$(upower --show-info $(upower --enumerate | grep -i 'BAT') | grep -E "state" | awk '{print $2}')" batstat="$(upower --show-info $(upower --enumerate | grep -i 'BAT') | grep -E "state" | awk '{print $2}')"
baticon='B'
if (( battpct > 80 )); then if (( battpct > 80 )); then
batclass=$fggreen batclass=$fggreen
elif (( battpct < 20 )); then elif (( battpct < 20 )); then
@ -350,17 +375,17 @@ segment_battery() {
batclass=$fgblue batclass=$fgblue
fi fi
if [ "$batstat" = "fully-charged" ]; then segment_text="$batclass"
baticon="${baticon}%{O3}⇈"
elif [ "$batstat" = "discharging" ]; then if [ "$batstat" = "charging" ]; then
baticon="${baticon}%{O3}↓"; segment_text="${segment_text}"
elif [ "$batstat" = "fully-charged" ]; then
segment_text="${segment_text}"
else else
baticon="${baticon}%{O3}↑"; append_battery_icon "$battpct"
fi fi
segment_text="$batclass" segment_text="$segment_text$fgend"
append_percent_icon "$battpct"
segment_text="$segment_text$baticon$fgend"
else else
segment_text="$fggreenﮣ$fgend" segment_text="$fggreenﮣ$fgend"
fi fi