* usr/lib/byobu/battery: LP: #1289157

- Mac OS X battery indicator support
This commit is contained in:
Dustin Kirkland 2014-03-17 09:55:26 +09:00
commit f20b760644
2 changed files with 30 additions and 0 deletions

5
debian/changelog vendored
View file

@ -1,5 +1,6 @@
byobu (5.75) unreleased; urgency=medium byobu (5.75) unreleased; urgency=medium
[ Dustin Kirkland ]
* debian/control: * debian/control:
- bump standards - bump standards
* usr/lib/byobu/include/shutil, usr/lib/byobu/release: LP: #1278016 * usr/lib/byobu/include/shutil, usr/lib/byobu/release: LP: #1278016
@ -19,6 +20,10 @@ byobu (5.75) unreleased; urgency=medium
- allow byobu-launch to pass arguments through to byobu-launcher - allow byobu-launch to pass arguments through to byobu-launcher
- fix up the uninstallation of byobu launcher - fix up the uninstallation of byobu launcher
[ Kosuke Asami ]
* usr/lib/byobu/battery: LP: #1289157
- Mac OS X battery indicator support
-- Dustin Kirkland <kirkland@ubuntu.com> Sun, 16 Mar 2014 12:46:36 -0700 -- Dustin Kirkland <kirkland@ubuntu.com> Sun, 16 Mar 2014 12:46:36 -0700
byobu (5.74-0ubuntu1) trusty; urgency=low byobu (5.74-0ubuntu1) trusty; urgency=low

View file

@ -31,6 +31,7 @@ __battery_detail() {
__battery() { __battery() {
local bat line present sign state percent full rem color bcolor local bat line present sign state percent full rem color bcolor
# Linux support
for bat in $BATTERY /sys/class/power_supply/* /proc/acpi/battery/*; do for bat in $BATTERY /sys/class/power_supply/* /proc/acpi/battery/*; do
present=""; full=""; rem=""; state="" present=""; full=""; rem=""; state=""
case "$bat" in case "$bat" in
@ -74,6 +75,30 @@ __battery() {
;; ;;
esac esac
done done
# Mac OS X support
if $BYOBU_TEST /usr/sbin/ioreg >/dev/null 2>&1; then
# MacOS support
local key
for key in CurrentCapacity MaxCapacity ExternalChargeCapable FullyCharged; do
line=$(/usr/sbin/ioreg -n AppleSmartBattery -w0 | grep $key | sed -e 's/|//g' | awk '{ print $3 }')
case "$key" in
CurrentCapacity) rem="$line";;
MaxCapacity) full="$line";;
ExternalChargeCapable)
if [ "${line}" = "Yes" ]; then
state="charging"
elif [ "${line}" = "No" ]; then
state="discharging"
fi
;;
FullyCharged)
if [ "${line}" = "Yes" ]; then
state="charged"
fi
;;
esac
done
fi
if [ $rem -ge 0 ] && [ $full -gt 0 ]; then if [ $rem -ge 0 ] && [ $full -gt 0 ]; then
percent=$(((100*$rem)/$full)) percent=$(((100*$rem)/$full))
if [ "$percent" -lt 33 ]; then if [ "$percent" -lt 33 ]; then