pwrcheck: A simple, scriptable, command-line utility to determine if you are running on battery or not. For Mac OS X.
Download: Current Version (.tar.gz) Older Versions
pwrcheck Returns 0 if the computer is running on AC power,
or 1 if it is running on battery. The source code includes a trivial
shell script check.sh
that shows one way how to use
pwrcheck to determine if running on battery.
% cat check.sh #!/bin/sh if pwrcheck ; then echo "On Mains" else echo "On Battery" fi % ./check.sh On Mains %
pwrcheck is released under the GNU General Public License.