diff options
author | Robby Russell <robby@planetargon.com> | 2013-04-23 19:44:11 -0700 |
---|---|---|
committer | Robby Russell <robby@planetargon.com> | 2013-04-23 19:44:11 -0700 |
commit | 56b4d4d6396087d5a94610e2b30638b62b9cbce1 (patch) | |
tree | 59d6633c68caad9012134063816d287f3b4d134b | |
parent | d8d9da025bacd451ead2bcf9197cdb6d0a9d80b2 (diff) | |
parent | bc385531b0e71b90b800502117bbdc8d1531e4c2 (diff) | |
download | zsh-56b4d4d6396087d5a94610e2b30638b62b9cbce1.tar.gz zsh-56b4d4d6396087d5a94610e2b30638b62b9cbce1.tar.bz2 zsh-56b4d4d6396087d5a94610e2b30638b62b9cbce1.zip |
Merge pull request #1738 from ronshapiro/master
Battery plugin changes
-rw-r--r-- | plugins/battery/battery.plugin.zsh | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index 95f890632..0c7c9421f 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -10,12 +10,16 @@ if [[ $(uname) == "Darwin" ]] ; then + function battery_pct() { + typeset -F maxcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //') + typeset -F currentcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //') + integer i=$(((currentcapacity/maxcapacity) * 100)) + echo $i + } + function battery_pct_remaining() { if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then - typeset -F maxcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //') - typeset -F currentcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //') - integer i=$(((currentcapacity/maxcapacity) * 100)) - echo $i + battery_pct else echo "External Power" fi |