From 6939b919c8a6b009e2c20595fffe745983254bdf Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Sat, 4 Jul 2015 07:59:30 -0600 Subject: [PATCH] * usr/lib/byobu/battery: - sum together all batteries --- debian/changelog | 3 ++- usr/lib/byobu/battery | 15 +++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/debian/changelog b/debian/changelog index a00537f3..37c35cd9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ byobu (5.95) unreleased; urgency=medium - * UNRELEASED + * usr/lib/byobu/battery: + - sum together all batteries -- Dustin Kirkland Wed, 17 Jun 2015 20:21:41 -0500 diff --git a/usr/lib/byobu/battery b/usr/lib/byobu/battery index cf4cfadd..b76c5289 100755 --- a/usr/lib/byobu/battery +++ b/usr/lib/byobu/battery @@ -32,8 +32,8 @@ __battery_detail() { __battery() { local bat line present sign state percent full rem color bcolor # Linux support + present=""; full="0"; rem="0"; state="" for bat in $BATTERY /sys/class/power_supply/* /proc/acpi/battery/*; do - present=""; full=""; rem=""; state="" case "$bat" in /sys/*) if [ -r "$bat/uevent" ]; then @@ -41,13 +41,12 @@ __battery() { case "$POWER_SUPPLY_NAME" in AC|ac|Ac|aC) continue ;; esac present="$POWER_SUPPLY_PRESENT" # Some use "CHARGE", others use "ENERGY", still others "CAPACITY" - [ -n "$POWER_SUPPLY_CAPACITY" ] && rem="$POWER_SUPPLY_CAPACITY" && full="100" - [ -n "$POWER_SUPPLY_CHARGE_FULL" ] && full="$POWER_SUPPLY_CHARGE_FULL" - [ -n "$POWER_SUPPLY_ENERGY_FULL" ] && full="$POWER_SUPPLY_ENERGY_FULL" - [ -n "$POWER_SUPPLY_CHARGE_NOW" ] && rem="$POWER_SUPPLY_CHARGE_NOW" - [ -n "$POWER_SUPPLY_ENERGY_NOW" ] && rem="$POWER_SUPPLY_ENERGY_NOW" - state="$POWER_SUPPLY_STATUS" - [ "$present" = "1" ] && [ -n "$full" ] && [ -n "$rem" ] && [ -n "$state" ] && break + #[ -n "$POWER_SUPPLY_CAPACITY" ] && rem="$POWER_SUPPLY_CAPACITY" && full="100" + [ -n "$POWER_SUPPLY_CHARGE_FULL" ] && full=$((POWER_SUPPLY_CHARGE_FULL+full)) + [ -n "$POWER_SUPPLY_ENERGY_FULL" ] && full=$((POWER_SUPPLY_ENERGY_FULL+full)) + [ -n "$POWER_SUPPLY_CHARGE_NOW" ] && rem=$((POWER_SUPPLY_CHARGE_NOW+rem)) + [ -n "$POWER_SUPPLY_ENERGY_NOW" ] && rem=$((POWER_SUPPLY_ENERGY_NOW+rem)) + [ "$POWER_SUPPLY_STATUS" != "Unknown" ] && state="$POWER_SUPPLY_STATUS" fi ;; /proc/*)