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