From 4435c0c4437ffaeb93df4973c928d9f20ba4f014 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Fri, 28 Feb 2014 17:18:36 -0600 Subject: [PATCH] * usr/lib/byobu/battery: LP: #1270451 - add support for yet another batter type (Android) - thanks to Felix Krull for the initial patch --- debian/changelog | 3 +++ usr/lib/byobu/battery | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/debian/changelog b/debian/changelog index f4e9012d..d99a47c9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,9 @@ byobu (5.74) unreleased; urgency=low https://github.com/erans/ec2instancespricing * usr/share/byobu/profiles/tmux: LP: #1273685 - remove double sourcing of local .tmux.conf + * usr/lib/byobu/battery: LP: #1270451 + - add support for yet another batter type (Android) + - thanks to Felix Krull for the initial patch [ Arminius Silvanus ] * usr/share/byobu/profiles/bashrc: LP: #1280550 diff --git a/usr/lib/byobu/battery b/usr/lib/byobu/battery index 911434c7..54d7182e 100755 --- a/usr/lib/byobu/battery +++ b/usr/lib/byobu/battery @@ -37,9 +37,10 @@ __battery() { /sys/*) if [ -r "$bat/uevent" ]; then . "$bat/uevent" - [ "$POWER_SUPPLY_NAME" = "AC" ] && continue + case "$POWER_SUPPLY_NAME" in AC|ac|Ac|aC) continue ;; esac present="$POWER_SUPPLY_PRESENT" - # Some use "CHARGE", others use "ENERGY" + # 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" @@ -86,10 +87,12 @@ __battery() { bcolor="b G k" fi percent="${percent}${PCT}" + # Convert state to lower case + state=$(printf "%s" "$state" | $BYOBU_SED 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/') case $state in - charging|Charging|Unknown) sign="+" ;; - discharging|Discharging) sign="-" ;; - charged|Unknown|Full) sign="="; percent="" ;; + charging) sign="+" ;; + discharging) sign="-" ;; + charged|unknown|full) sign="=" ;; *) sign="$state" ;; esac if [ -z "$percent" ]; then