summaryrefslogtreecommitdiff
path: root/plugins/battery/battery.plugin.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/battery/battery.plugin.zsh')
-rw-r--r--plugins/battery/battery.plugin.zsh12
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