From b79fc5d03e7aa571ba57cb228983be08bdf944b2 Mon Sep 17 00:00:00 2001 From: Jesus de Mula Cano Date: Mon, 7 Mar 2011 01:26:24 +0100 Subject: [PATCH] Add beginings of mac os support for the battery plugin --- plugins/battery.plugin.bash | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/battery.plugin.bash b/plugins/battery.plugin.bash index db1d6f9..00f283c 100644 --- a/plugins/battery.plugin.bash +++ b/plugins/battery.plugin.bash @@ -24,8 +24,17 @@ battery_percentage(){ elif command_exists ioreg; then # http://hints.macworld.com/article.php?story=20100130123935998 - local IOREG_OUTPUT_10_6=$(ioreg -l | grep -i capacity | tr '\n' ' | ' | awk '{printf("%.2f%%", $10/$5 * 100)}') - local IOREG_OUTPUT_10_5=$(ioreg -l | grep -i capacity | grep -v Legacy| tr '\n' ' | ' | awk '{printf("%.2f%%", $14/$7 * 100)}') + #local IOREG_OUTPUT_10_6=$(ioreg -l | grep -i capacity | tr '\n' ' | ' | awk '{printf("%.2f%%", $10/$5 * 100)}') + #local IOREG_OUTPUT_10_5=$(ioreg -l | grep -i capacity | grep -v Legacy| tr '\n' ' | ' | awk '{printf("%.2f%%", $14/$7 * 100)}') + local IOREG_OUTPUT=$(ioreg -n AppleSmartBattery -r | awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%.2f%%"; max=c["\"MaxCapacity\""]; print (max>0? 100*c["\"CurrentCapacity\""]/max: "?")}') + case $IOREG_OUTPUT in + 100*) + echo '99' + ;; + *) + echo $IOREG_OUTPUT | head -c 2 + ;; + esac else echo "no" fi -- 2.17.1