Difference between revisions of "MacBuild Battery Test"

From FreekiWiki
Jump to navigation Jump to search
(New page: This is the battery test currently used on laptops coming out of MacBuild. ==Code== #!/bin/bash #macbuild battery test BATFI=$HOME/bat_mon if [ -f "$BATFI" ]; then MINZ=$(wc -l...)
 
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This is the battery test currently used on laptops coming out of MacBuild.
+
---THIS SCRIPT IS NO LONGER IN USE---
 +
 
 +
Coconutbattery is used to determine battery capacity percentage
 +
 
 +
[[User:Lynnae|Lynnae]] 17:34, 21 June 2012 (UTC)
 +
 
 +
 
 +
 
 
==Code==
 
==Code==
  
Line 30: Line 37:
  
 
Once the system's battery has been drained, reconnect power to the system, power it on, navigate to the directory with the battery test script via the terminal, and run it again.  It should see that "bat_mon" exists and tell you how long the battery lasted.
 
Once the system's battery has been drained, reconnect power to the system, power it on, navigate to the directory with the battery test script via the terminal, and run it again.  It should see that "bat_mon" exists and tell you how long the battery lasted.
 +
 +
[[Category:Delete]]

Latest revision as of 17:48, 11 September 2013

---THIS SCRIPT IS NO LONGER IN USE---

Coconutbattery is used to determine battery capacity percentage

Lynnae 17:34, 21 June 2012 (UTC)


Code

#!/bin/bash
#macbuild battery test

BATFI=$HOME/bat_mon

if [ -f "$BATFI" ]; then
  MINZ=$(wc -l "$BATFI" | awk '{print $1}')
  echo "battery lasted $MINZ minutes"
else  
  while sleep 60; do
    echo "testing battery life!" | tee -a $BATFI
  done
fi

How it works

This script is pretty straightforward: when you run it on a system for the first time, it creates a file called "bat_mon" in the user's home directory, echoes "testing battery life!" in the terminal every 60 seconds, and appends the line to "bat_mon". Essentially each new "testing battery life!" line in "bat_mon" is equal to a minute of runtime. When you run this on a system the second time, the script will realize "bat_mon" already exists, count the lines in the file, and tell you how many minutes the battery lasted. Keep in mind that you will have to delete "bat_mon" if you want to run the script anew.

How to use it

You can either copy the code above and save it to [filename].sh (the name can be whatever you want, but make sure it ends in .sh) or download it from here.

Once you've got the script set up, go ahead and set up the system for the battery test (e.g. disable the screensaver, put an audio CD in the system's optical drive, set whatever media player to repeat, play the disc, and disconnect the system's power supply)

You then have to open up a terminal, navigate to the directory the file is in, and type:

oem@macbox:~$ sh [filename].sh

to start it, replacing [filename] with whatever you called it. Keep the terminal open while the script is running.

Once the system's battery has been drained, reconnect power to the system, power it on, navigate to the directory with the battery test script via the terminal, and run it again. It should see that "bat_mon" exists and tell you how long the battery lasted.