From cad4ac1b6539dd92d4bb7983862be282026b8586 Mon Sep 17 00:00:00 2001 From: Breizh Date: Fri, 8 Mar 2024 23:18:57 +0100 Subject: [PATCH] Actualiser .i3blocks/batterybar --- .i3blocks/batterybar | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.i3blocks/batterybar b/.i3blocks/batterybar index fdd1d93..e634cf0 100755 --- a/.i3blocks/batterybar +++ b/.i3blocks/batterybar @@ -17,9 +17,9 @@ human_time() { source /sys/class/power_supply/BAT1/uevent time="$(date +%s)" -# Min et max hardcodés (20 et 80 % ici) -MIN=1112600 -MAX=4452000 +# Min et max personnalisés (20 et 80 % ici) +MIN="$(( POWER_SUPPLY_CHARGE_FULL * 2 / 10 ))" +MAX="$(( POWER_SUPPLY_CHARGE_FULL * 8 / 10 ))" # Utiliser toute la plage de la batterie #MIN=0 @@ -62,6 +62,8 @@ else remaining_secs=0 fi +[[ "$remaining_secs" -lt 0 ]] && remaining_secs=0 + remaining="$(human_time "$remaining_secs")" # Définition des couleurs @@ -143,7 +145,7 @@ case "${status}" in color="$ac_color" ;; "Discharging"|"Unknown") - if (( percentage >= 0 && percentage < 10 )); then + if (( percentage < 10 )); then color="${dis_colors[0]}" elif (( percentage >= 10 && percentage < 20 )); then color="${dis_colors[1]}" @@ -175,3 +177,4 @@ fi # Affichage echo "bat $message" echo "bat ${percentage}%" +declare -p MIN MAX percents percentage >&2