diff options
author | Ron Shapiro <shapiro.rd@gmail.com> | 2013-04-29 10:18:32 -0400 |
---|---|---|
committer | Ron Shapiro <shapiro.rd@gmail.com> | 2013-04-29 10:18:32 -0400 |
commit | ae1973de443525daeb87df9973ae83c6c9210cfe (patch) | |
tree | 11da5ef3ce7b234d42fb699295dbf7a1f6751795 /plugins/battery/battery.plugin.zsh | |
parent | bc385531b0e71b90b800502117bbdc8d1531e4c2 (diff) | |
download | zsh-ae1973de443525daeb87df9973ae83c6c9210cfe.tar.gz zsh-ae1973de443525daeb87df9973ae83c6c9210cfe.tar.bz2 zsh-ae1973de443525daeb87df9973ae83c6c9210cfe.zip |
plugged_in function
Diffstat (limited to 'plugins/battery/battery.plugin.zsh')
-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 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 } |