diff options
author | Bob Williams <bobwilliams.ii@gmail.com> | 2014-03-14 10:32:03 -0400 |
---|---|---|
committer | Bob Williams <bobwilliams.ii@gmail.com> | 2014-03-14 10:32:03 -0400 |
commit | 223fd60ba597b8c23569c65878d766c3c933fa70 (patch) | |
tree | 33c5c6a150293e6cf81f26f0f1b9c733dcf8aab7 /plugins/battery | |
parent | 185cb6e37352cc0d92042e35d259b0de3f5f3886 (diff) | |
parent | ee21fe94473404b58cbaea5b2c279f7a07c34ce1 (diff) | |
download | zsh-223fd60ba597b8c23569c65878d766c3c933fa70.tar.gz zsh-223fd60ba597b8c23569c65878d766c3c933fa70.tar.bz2 zsh-223fd60ba597b8c23569c65878d766c3c933fa70.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'plugins/battery')
-rw-r--r-- | plugins/battery/battery.plugin.zsh | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index 16ad3e651..e39cc5b8f 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -17,12 +17,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 } |