When I arrived to pyCamp (I'm at pyCamp!) I was fighting with a battery applet bug. When the battery is almost full the applet got 'confused' and thought the battery just finished charging, and if it where showing the remaining time, it switched to charge percentage, which actually showed that it wasn't fully charged, but somewhere near 96% or so (this is wrong assuming the battery can fully charge up to 100%, as my 6 month old Dell battery). The problem was really that my code was checking if the remaining time were 0 or not. So I started from there down.
Down was it indeed. Seems like from time to time, when the
bettry is filling up, one can't ask hal about the remaining time.
Using qdbus to ask hal directly we get
this answer:
Error: org.freedesktop.Hal.NoSuchProperty
No property battery.remaining_time on device
This situation is not stable; sometimes I get the value I want. Not only that, when the battery is full, the values get horrobly wrong. Here's some samples (values are seconds since epoch and remaining time in seconds):
1237677446 1134
1237677746 261
1237677806 235
1237677866 313
1237677927 190
# at some moment in this gap the battery is fully charged
1237678167 188836
1237678227 152509
1237678287 112581
So I changed the algorithm to a more correct one; that is, ask if the battery is charging or discharging or none of those (in that case the battery is full) and show the time or the percentage accordingly. This works, except that it doesn't.
The problem has shifted to another place. Now I don't get the
signal when is_chaging goes false. With lshal
-m I can see the event:
11:48:46.823: computer_power_supply_battery_BAT0 property battery.rechargeable.is_charging = false
but I keep getting "Charging" from this code:
battery_data.value()["State"].toString()
where battery is a powermanagement data engine.
Interesting enough, if I close the applet and load it again (as
anyone debugging plasmoids, I'm using plasmoidviewer),
that line returns the correct value of "NoCharge",
which is what's spected.
I will try to file a bug against the data engine, or maybe Solid, and wait for the fix before comitting the fix to this bug.
Update: it ended being a bug in Solid, after all. I posted a fix.