From 43511f6f15375236d575a043f0806fd1a27e6c0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Mengu=C3=A9?= Date: Mon, 13 May 2013 20:40:04 +0200 Subject: [PATCH] _lp_color_map: use dichotomy to more evenly distribute cost --- liquidprompt | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/liquidprompt b/liquidprompt index 1e14ad4..e64c9c4 100755 --- a/liquidprompt +++ b/liquidprompt @@ -1129,22 +1129,28 @@ _lp_battery_color() _lp_color_map() { local -i load load=$1 - if (( load < 20 )); then - echo -ne "${LP_COLORMAP_0}" - elif (( load < 40 )); then - echo -ne "${LP_COLORMAP_1}" - elif (( load < 60 )); then - echo -ne "${LP_COLORMAP_2}" - elif (( load < 80 )); then - echo -ne "${LP_COLORMAP_3}" - elif (( load < 100 )); then - echo -ne "${LP_COLORMAP_4}" - elif (( load < 120 )); then - echo -ne "${LP_COLORMAP_5}" - elif (( load < 140 )); then - echo -ne "${LP_COLORMAP_6}" + if (( load < 100 )); then + if (( load < 60 )); then + if (( load < 20 )); then + echo -ne "${LP_COLORMAP_0}" + elif (( load < 40 )); then + echo -ne "${LP_COLORMAP_1}" + else # 40..59 + echo -ne "${LP_COLORMAP_2}" + fi + elif (( load < 80 )); then + echo -ne "${LP_COLORMAP_3}" + else # 80..99 + echo -ne "${LP_COLORMAP_4}" + fi elif (( load < 160 )); then - echo -ne "${LP_COLORMAP_7}" + if (( load < 120 )); then + echo -ne "${LP_COLORMAP_5}" + elif (( load < 140 )); then + echo -ne "${LP_COLORMAP_6}" + else + echo -ne "${LP_COLORMAP_7}" + fi elif (( load < 180 )) ; then echo -ne "${LP_COLORMAP_8}" else # (( load >= 180 ))