Some notebooks do not provide power usage data. This code tries
to estimate the current power usage by measuring the battery level
difference in a specific time interval.
Hotplug
Hi,
So I went on and added the hotplug stuff. It's currently used for two things:
1. reconfigure battery if a power_supply add/remove event has been received (e.g. new battery)
2. update battery if a power_supply change event has been received (e.g. sent for AC connect/disconnect)
The second one is useful to make "ac_connect_cmd" and "ac_disconnect_cmd"
react instantly. Otherwise they are only executed when the battery update
routine is scheduled again. It does not introduce any new library dependencies
and the kernel interface is considered as ABI, so there won't be any frequent changes.
I also added a little fix on top, that prevents ac_connect_cmd execution
during tint2 startup (with AC connected).
-- Sebastian
See merge request !10
The Kernel sends notifications for AC (un)plug and some
other important power supply events, so that we can
instantly update the widget. Apart from that it sends
notifications for any added or removed power supplies,
so that the battery support can be reinitialized (useful
on systems with removable batteries).
Avoid linking against disabled features
If rsvg or startup-notification features are disabled, the
binary should not be linked against the associated libraries.
See merge request !9
Misc battery updates
Hi,
So here are a couple of more patches. I did only minimal testing for the battery BSD stuff
(basically compilation under Linux and check, that only sensible errors appear). The second
patch (remove static clock tooltip buffer) is independent of the remaining changes, but
depends on the first patch.
I guess the battery code for Linux could be further improved by using libudev
to handle kernel events for added batteries and AC plug changes.
-- Sebastian
See merge request !8
This add two new config options "ac_connected_cmd" and
"ac_disconnected_cmd". These commands are executed when
AC (mains supply) is connected or disconnected.
This removes all operating system specific code from the main
battery file into their own source files. CMake will add the
correct implementation automatically.
Add initial support for mains/ac adapters. This adds the
state only to the tooltip, but the code has been prepared
to update AC state together with normal battery updates,
so that it's possible to forward the state to the normal
panel area or trigger something on AC (dis)connection.
Only Linux provides detailed energy statistics. The BSDs directly
provide percentage values. This change makes it easier to split
out the BSD code and reduces code overhead on BSD systems.