power.battery
The power.battery property gets the current battery usage as a table. If no battery is present, the property returns nil.
The table provides the following fields :
charging: indicates if the battery is charging or not.percent: indicates the battery left, in percent.lifetime: indicates the battery lifetime in seconds ornilif the system cannot calculate it.saver: indicates if the battery saver is currently in use.
Example
--! luart-extensions
import power
if power.battery then
print("Battery is "..(power.battery.charging and "charging" or "not charging"))
print(power.battery.percent.."% left")
print(power.battery.lifetime and math.floor(power.battery.lifetime/3600).."h remaining" or "Battery lifetime not available")
print(power.battery.saver and "Battery saver is in use" or "Battery saver is not in use")
else
print("This computer don't have a battery")
end