Switch to 8 levels of vertical bar for battery icon.

This commit is contained in:
Tom Alexander 2023-03-18 18:29:06 -04:00
parent 11b9a08635
commit ee1899cf4d
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 43 additions and 24 deletions

View File

@ -1 +1,2 @@
rust_date: "2022-10-14" # Check that rust-analyzer is valid for date on https://rust-lang.github.io/rustup-components-history/
rust_date: "2023-03-18"

View File

@ -25,18 +25,24 @@ while true; do
else else
battery_icon="⚡" battery_icon="⚡"
fi fi
elif [ $battery_percentage -le 20 ]; then elif [ $battery_percentage -le 12 ]; then
battery_icon="○"# ⚠ battery_icon="⚠"
elif [ $battery_percentage -le 40 ]; then elif [ $battery_percentage -le 25 ]; then
battery_icon="◔" battery_icon="▁"
elif [ $battery_percentage -le 60 ]; then elif [ $battery_percentage -le 37 ]; then
battery_icon="◑" battery_icon="▂"
elif [ $battery_percentage -le 80 ]; then elif [ $battery_percentage -le 50 ]; then
battery_icon="◕" battery_icon="▃"
elif [ $battery_percentage -le 62 ]; then
battery_icon="▄"
elif [ $battery_percentage -le 75 ]; then
battery_icon="▅"
elif [ $battery_percentage -le 87 ]; then
battery_icon="▆"
elif [ $battery_percentage -lt 100 ]; then elif [ $battery_percentage -lt 100 ]; then
battery_icon="●" battery_icon=""
else else
battery_icon="●"# █▇▆▅▄▃▂▁ ⚠ ▕▅▏ battery_icon="█"
fi fi
if [ $battery_percentage -le 15 ]; then if [ $battery_percentage -le 15 ]; then

View File

@ -13,33 +13,45 @@ function generate_battery_update {
local battery_state=$(grep 'state:' <<<"$battery_status" | awk '{print $2}') local battery_state=$(grep 'state:' <<<"$battery_status" | awk '{print $2}')
local battery_percentage=$(grep 'percentage:' <<<"$battery_status" | awk '{print $2}') local battery_percentage=$(grep 'percentage:' <<<"$battery_status" | awk '{print $2}')
battery_percentage=${battery_percentage%\%} battery_percentage=${battery_percentage%\%}
set +e
local time_remaining=$(grep 'time to empty:' <<<"$battery_status" | sed 's/\W*time to empty:\W*//g') local time_remaining=$(grep 'time to empty:' <<<"$battery_status" | sed 's/\W*time to empty:\W*//g')
local tooltip="$time_remaining until empty" local tooltip="$time_remaining until empty"
if [ -z "$time_remaining" ]; then if [ -z "$time_remaining" ]; then
time_remaining=$(grep 'time to full:' <<<"$battery_status" | sed 's/\W*time to full:\W*//g') time_remaining=$(grep 'time to full:' <<<"$battery_status" | sed 's/\W*time to full:\W*//g')
tooltip="$time_remaining until full" if [ -z "$time_remaining" ]; then
tooltip="fully charged"
else
tooltip="$time_remaining until full"
fi
fi fi
set -e
local battery_icon="" local battery_icon=""
local class="" local class=""
if [ $battery_state = "charging" ]; then if [ $battery_state = "charging" ]; then
if [ $battery_percentage -eq 100 ]; then if [ $battery_percentage -eq 100 ]; then
battery_icon="" battery_icon=""
else else
battery_icon="" battery_icon=""
fi fi
elif [ $battery_percentage -le 20 ]; then elif [ $battery_percentage -le 12 ]; then
battery_icon="⚋" battery_icon="⚠"
elif [ $battery_percentage -le 40 ]; then elif [ $battery_percentage -le 25 ]; then
battery_icon="⚊" battery_icon="▁"
elif [ $battery_percentage -le 60 ]; then elif [ $battery_percentage -le 37 ]; then
battery_icon="⚍" battery_icon="▂"
elif [ $battery_percentage -le 80 ]; then elif [ $battery_percentage -le 50 ]; then
battery_icon="⚌" battery_icon="▃"
elif [ $battery_percentage -le 62 ]; then
battery_icon="▄"
elif [ $battery_percentage -le 75 ]; then
battery_icon="▅"
elif [ $battery_percentage -le 87 ]; then
battery_icon="▆"
elif [ $battery_percentage -lt 100 ]; then elif [ $battery_percentage -lt 100 ]; then
battery_icon="☱" battery_icon=""
else else
battery_icon="☰" battery_icon=""
fi fi
if [ $battery_percentage -le 15 ]; then if [ $battery_percentage -le 15 ]; then