From b61704d4a7f163e690bcd6767e0106f0a6046351 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Tue, 13 Aug 2013 09:30:12 -0500 Subject: [PATCH] * usr/lib/byobu/battery: - fix battery status caching issues when battery is full, or plugged into AC --- debian/changelog | 4 +++- usr/lib/byobu/battery | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 5891404d..7a35f9b9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ byobu (5.56) unreleased; urgency=low - * UNRELEASED + * usr/lib/byobu/battery: + - fix battery status caching issues when battery is full, or + plugged into AC -- Dustin Kirkland Sat, 10 Aug 2013 09:23:04 +0100 diff --git a/usr/lib/byobu/battery b/usr/lib/byobu/battery index a152a30a..911434c7 100755 --- a/usr/lib/byobu/battery +++ b/usr/lib/byobu/battery @@ -37,6 +37,7 @@ __battery() { /sys/*) if [ -r "$bat/uevent" ]; then . "$bat/uevent" + [ "$POWER_SUPPLY_NAME" = "AC" ] && continue present="$POWER_SUPPLY_PRESENT" # Some use "CHARGE", others use "ENERGY" [ -n "$POWER_SUPPLY_CHARGE_FULL" ] && full="$POWER_SUPPLY_CHARGE_FULL" @@ -84,14 +85,17 @@ __battery() { color="G k" bcolor="b G k" fi - percent="$percent$PCT" + percent="${percent}${PCT}" case $state in charging|Charging|Unknown) sign="+" ;; discharging|Discharging) sign="-" ;; charged|Unknown|Full) sign="="; percent="" ;; *) sign="$state" ;; esac - [ -n "$percent" ] || return + if [ -z "$percent" ]; then + rm -f "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/battery"* + return + fi color $bcolor; printf "%s" "$percent"; color -; color $color; printf "%s" "$sign"; color -- fi }