From ae1973de443525daeb87df9973ae83c6c9210cfe Mon Sep 17 00:00:00 2001 From: Ron Shapiro Date: Mon, 29 Apr 2013 10:18:32 -0400 Subject: [PATCH] plugged_in function --- plugins/battery/battery.plugin.zsh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index 0c7c9421f..785386a12 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -16,12 +16,16 @@ if [[ $(uname) == "Darwin" ]] ; then integer i=$(((currentcapacity/maxcapacity) * 100)) echo $i } + + function plugged_in() { + [ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ Yes') -eq 1 ] + } function battery_pct_remaining() { - if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then - battery_pct - else + if plugged_in ; then echo "External Power" + else + battery_pct fi }