summaryrefslogtreecommitdiff
path: root/plugins/battery
diff options
context:
space:
mode:
authorRon Shapiro <shapiro.rd@gmail.com>2013-04-29 10:18:32 -0400
committerRon Shapiro <shapiro.rd@gmail.com>2013-04-29 10:18:32 -0400
commitae1973de443525daeb87df9973ae83c6c9210cfe (patch)
tree11da5ef3ce7b234d42fb699295dbf7a1f6751795 /plugins/battery
parentbc385531b0e71b90b800502117bbdc8d1531e4c2 (diff)
downloadzsh-ae1973de443525daeb87df9973ae83c6c9210cfe.tar.gz
zsh-ae1973de443525daeb87df9973ae83c6c9210cfe.tar.bz2
zsh-ae1973de443525daeb87df9973ae83c6c9210cfe.zip
plugged_in function
Diffstat (limited to 'plugins/battery')
-rw-r--r--plugins/battery/battery.plugin.zsh10
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
}