Vote
Bury
10

Battery Status

Posted in System by Khelmar 82 days ago
This lists the battery status for MacBooks, and the current % if not attached to an AC adapter.

The shell script is:

my_ac_adapt=`ioreg -w0 -l | grep ExternalConnected | awk '{print $5}'`
if [ "$my_ac_adapt" == "Yes" ]
then
echo "Power : External"
else
cur_power=`ioreg -w0 -l | grep CurrentCapacity | awk '{print $5}'`
max_power=`ioreg -w0 -l | grep MaxCapacity | awk '{print $5}'`
bat_percent=`echo "scale=2;$cur_power / $max_power" | bc`
bat_percent=`echo "$bat_percent * 100" | bc | sed 's/.00//'`
cyc_count=`ioreg -w0 -l | grep "Cycle Count" | awk 'BEGIN { FS = "=" } ; {print $8}' | awk 'BEGIN { FS = "}" } ; {print $1}'`
echo "Power : Battery ($bat_percent%)"
echo "Cycles : $cyc_count"
fi


Just paste that into a file, set it executable, and run it as a shell command under GeekTool.

Comments


Written by beiju
82 days ago
test
Is it possible to have it return successful when the battery is above, say, 10% but show GeekTool's "Failure" image when it gets below that?



Log in to comment or register here.
Geeklets are little bits of text, images or information that you can display on your desktop using the free GeekTool software.
Read more...
Advertisement

Advertise Here

Username:

Password:

Remember: