56b4d4d6396087d5a94610e2b30638b62b9cbce1
- Author
- Robby Russell <robby@planetargon.com>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Merge pull request #1738 from ronshapiro/master
Battery plugin changes
Diff
1diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh
2index 95f8906321a948c4d0228c6ba0f580cd67556d73..0c7c9421fe34a777d43a234c2f8daf20979c9c81 100644
3--- a/plugins/battery/battery.plugin.zsh
4+++ b/plugins/battery/battery.plugin.zsh
5@@ -10,12 +10,16 @@
6
7 if [[ $(uname) == "Darwin" ]] ; then
8
9+ function battery_pct() {
10+ typeset -F maxcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //')
11+ typeset -F currentcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //')
12+ integer i=$(((currentcapacity/maxcapacity) * 100))
13+ echo $i
14+ }
15+
16 function battery_pct_remaining() {
17 if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then
18- typeset -F maxcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //')
19- typeset -F currentcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //')
20- integer i=$(((currentcapacity/maxcapacity) * 100))
21- echo $i
22+ battery_pct
23 else
24 echo "External Power"
25 fi