ae1973de443525daeb87df9973ae83c6c9210cfe
- Author
- Ron Shapiro <shapiro.rd@gmail.com>
- Committer
- Ron Shapiro <shapiro.rd@gmail.com>
- Date
Message
plugged_in function
Diff
1diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh
2index 0c7c9421fe34a777d43a234c2f8daf20979c9c81..785386a12e57d7a27d8b66e78b8d1e363094036b 100644
3--- a/plugins/battery/battery.plugin.zsh
4+++ b/plugins/battery/battery.plugin.zsh
5@@ -16,12 +16,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