If you are running in the text mode and want to find out if your laptop is running on battery or on ac power you can use the command "on_ac_power".
The command returns "0" if laptop is running on ac power, 1 if it is runnning on battery and 255 if it can not determine.
$ echo $?
Thus the laptop is running on ac power.
You can use the following script to make the output look more user friendly.
if [ $? -eq 0 ]
echo "Running on ac power"
elif [ $? -eq 1 ]
echo "Running on Battery"
echo "Can not detemine"
Save the script as power.sh and run it as follows.
$ sh power.sh
Running on ac power
Thus giving the required information in more readable format.