Skip to content

Commit

Permalink
-Fix: display first (0th) battery status from acpi output
Browse files Browse the repository at this point in the history
  • Loading branch information
xhabit committed May 22, 2019
1 parent ff4238c commit a654ed2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions git-prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -607,17 +607,17 @@ create_battery_indicator () {
battery_string=$(acpi -b)

if [[ $battery_string ]]; then
tmp=${battery_string%\%*}
tmp=${battery_string%%\%*}
battery_percent=${tmp##* }
if [[ "$battery_string" =~ "Discharging" ]]; then
if [[ "$tmp" =~ "Discharging" ]]; then
if [[ $utf8_prompt ]]; then
battery_diagrams=( ▕▁▏ ▕▂▏ ▕▃▏ ▕▄▏ ▕▅▏ ▕▆▏ ▕▇▏ ▕█▏ )
battery_pwr_index=$(($battery_percent/13))
battery_indicator=${battery_diagrams[battery_pwr_index]}
else
battery_indicator="|$battery_percent|"
fi
elif [[ "$battery_string" =~ "Charging" ]]; then
elif [[ "$tmp" =~ "Charging" ]]; then
if [[ $utf8_prompt ]]; then
battery_indicator="▕⚡▏"
else
Expand Down

0 comments on commit a654ed2

Please sign in to comment.