Add beginings of mac os support for the battery plugin
parent
f98a728866
commit
b79fc5d03e
|
|
@ -24,8 +24,17 @@ battery_percentage(){
|
||||||
elif command_exists ioreg;
|
elif command_exists ioreg;
|
||||||
then
|
then
|
||||||
# http://hints.macworld.com/article.php?story=20100130123935998
|
# 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_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_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
|
else
|
||||||
echo "no"
|
echo "no"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue