Where does gnome-power-statistics get its data from?

Gnome-power-statistics is run when you click on the battery icon in the top panel of a laptop. It shows battery history such as charge and rate, as well as statistics such as discharge profile and discharge accuracy.

gnome power statistics discharge profile

The more you use your laptop, the more data it shows, and the more accurate the battery time-to-empty predictions are.

So, where does gnome-power-statistics get the raw historical data from? And, if it also saves any data, where does it save it to?


I've just answered a simular question here, but here is the summary:

UPower's historical information is stored in four files in /var/lib/upower/, yours will be different but mine are named:

./var/lib/upower/history-time-empty-DELL_KP4377-57-22096.dat
./var/lib/upower/history-time-full-DELL_KP4377-57-22096.dat
./var/lib/upower/history-charge-DELL_KP4377-57-22096.dat
./var/lib/upower/history-rate-DELL_KP4377-57-22096.dat

It appears to compile this data from the information in /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0 which I'm guessing is in turn directly taken from acpi's information on the current battery state at /proc/acpi/battery/BAT0/info.

Hope this helps.


Ubuntu uses upower (version 10.4+). Older versions used DeviceKit-power (9.10) or HAL (<9.10).

Regarding upower:

UPower is an abstraction for enumerating power devices, listening to device events and querying history and statistics. Any application or service on the system can access the org.freedesktop.UPower service via the system message bus. Some operations (such as suspending the system) are restricted using PolicyKit.

UPower was once called DeviceKit-power. UPower aims to make a large chunk of HAL redundant, as HAL is officially deprecated.

  • UPower Reference Manual
  • UPower Reference Manual: devices

From the last link: The org.freedesktop.UPower API has a org.freedesktop.UPower.Device and that one has a ...

GetStatistics ()

GetStatistics (in  's'     type,               out 'a(dd)' data)

Gets statistics for the power device that may be interesting to show 
on a graph in the session.

type: The mode for the statistics. Valid types are charging or discharging.
data: The statistics data for the power device. 

Each element contains the following members:
value: The value of the percentage point, usually in seconds
accuracy: The accuracy of the prediction in percent.

to provide data that is used in the graph. I think that the data is cleared when you reboot/shutdown so it is probably real-time and has no history.