From 658cfb7d6e2cb54c20c6cce0eff5b794fab6a07d Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Tue, 4 Aug 2015 11:28:47 +0200 Subject: [PATCH] Fixed battery conversion For battery percentages of 08 and 09 percent, the `-le` would fail with an error ("value too great for base"), since the numbers with leading zeros are treated as octal numbers when using double brackets. The solution is to force base 10 for the numbers. More details here: http://stackoverflow.com/a/24777667/1228454 --- themes/powerline-multiline/powerline-multiline.theme.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index 6940b9ee..66f57241 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -172,9 +172,9 @@ function powerline_battery_status_prompt { if [[ -z "${BATTERY_STATUS}" ]] || [[ "${BATTERY_STATUS}" = "-1" ]] || [[ "${BATTERY_STATUS}" = "no" ]]; then BATTERY_PROMPT="" else - if [[ "${BATTERY_STATUS}" -le 5 ]]; then + if [[ "$((10#${BATTERY_STATUS}))" -le 5 ]]; then BATTERY_STATUS_THEME_PROMPT_COLOR="${BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR}" - elif [[ "${BATTERY_STATUS}" -le 25 ]]; then + elif [[ "$((10#${BATTERY_STATUS}))" -le 25 ]]; then BATTERY_STATUS_THEME_PROMPT_COLOR="${BATTERY_STATUS_THEME_PROMPT_LOW_COLOR}" else BATTERY_STATUS_THEME_PROMPT_COLOR="${BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR}"