Calculate time left until battery is discharged?
<p>I want to calculate the time until the battery in my laptop has discharged. The data I can use is available via sysfs, but I'm not sure which files and algorithm to use:</p>

<pre><code>$ ls /sys/class/power_supply/BAT0/ | sort
alarm
charge_full
charge_full_design
charge_now
current_now
cycle_count
device
manufacturer
model_name
power
present
serial_number
status
subsystem
technology
type
uevent
voltage_min_design
voltage_no
</code></pre>

<p>What is the correct algorithm to determine time left in hours and minutes before the battery is empty?</p>