Actualiser .i3blocks/batterybar

This commit is contained in:
Breizh 2024-03-08 23:18:57 +01:00
parent 98d40925ca
commit cad4ac1b65

View file

@ -17,9 +17,9 @@ human_time() {
source /sys/class/power_supply/BAT1/uevent source /sys/class/power_supply/BAT1/uevent
time="$(date +%s)" time="$(date +%s)"
# Min et max hardcodés (20 et 80% ici) # Min et max personnalisés (20 et 80% ici)
MIN=1112600 MIN="$(( POWER_SUPPLY_CHARGE_FULL * 2 / 10 ))"
MAX=4452000 MAX="$(( POWER_SUPPLY_CHARGE_FULL * 8 / 10 ))"
# Utiliser toute la plage de la batterie # Utiliser toute la plage de la batterie
#MIN=0 #MIN=0
@ -62,6 +62,8 @@ else
remaining_secs=0 remaining_secs=0
fi fi
[[ "$remaining_secs" -lt 0 ]] && remaining_secs=0
remaining="$(human_time "$remaining_secs")" remaining="$(human_time "$remaining_secs")"
# Définition des couleurs # Définition des couleurs
@ -143,7 +145,7 @@ case "${status}" in
color="$ac_color" color="$ac_color"
;; ;;
"Discharging"|"Unknown") "Discharging"|"Unknown")
if (( percentage >= 0 && percentage < 10 )); then if (( percentage < 10 )); then
color="${dis_colors[0]}" color="${dis_colors[0]}"
elif (( percentage >= 10 && percentage < 20 )); then elif (( percentage >= 10 && percentage < 20 )); then
color="${dis_colors[1]}" color="${dis_colors[1]}"
@ -175,3 +177,4 @@ fi
# Affichage # Affichage
echo "bat $message" echo "bat $message"
echo "bat <span foreground=\"$color\">${percentage}%</span>" echo "bat <span foreground=\"$color\">${percentage}%</span>"
declare -p MIN MAX percents percentage >&2