Skip to content

Commit

Permalink
ensure max is 100 if file does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
anlutro committed Apr 12, 2024
1 parent d52af1d commit fe824cd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions configs/i3/block-scripts/battery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pct=$(echo "$full_text" | cut -d, -f2 | sed s/%// | tr -d '[:space:]')
if ! echo "$full_text" | grep -qF -e 'rate information unavailable' -e 'zero rate'; then
remaining=$(echo "$full_text" | cut -d, -f3 | cut -d' ' -f2)
fi
max=$(cat /sys/class/power_supply/BAT0/charge_control_end_threshold)
max=$(cat /sys/class/power_supply/BAT0/charge_control_end_threshold || echo 100)

if [ "$status" = 'Unknown' ]; then
status="Full"
Expand All @@ -17,7 +17,7 @@ text="$status $pct%"
if [ -n "${remaining-}" ]; then
text="$text $remaining"
fi
if [ "${max:-100}" -lt 100 ]; then
if [ $max -lt 100 ]; then
text="$text (max:$max%)"
fi

Expand Down

0 comments on commit fe824cd

Please sign in to comment.