g-p-m does not allow using battery percentage for policy in feisty

Bug #113244 reported by godlygeek
6
Affects Status Importance Assigned to Milestone
gnome-power-manager (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Binary package hint: gnome-power-manager

In my experience, it does not seem to be possible to get g-p-m to use battery percent remaining, rather than battery time remaining, as the metric determining the current power state.

Steps to reproduce:

1. open gconf-editor
2. navigate to /apps/gnome-power-manager
3. uncheck key "use_time_for_policy" to switch to using battery percentage, rather than time, as the metric.
4. set key "battery_percentage_action" to value "99", which should ensure that an action is taken once the battery is <= 99%
5. set key "action_battery_critical" to value "suspend", to suspend the machine once the battery is <= 99%
6. unplug your laptop. The machine should suspend within a few minutes, when the battery percentage drops from 100% to 99%.
7. observe as the laptop does not suspend.

If my source-diving is correct, this is due to a line in gpm_warning_get_state() in gpm-warning.c, line 102:

we initialize policy to warning->priv->use_time, which equals 0, since we want to use percent.
Then, we compare policy to GPM_WARNING_TIME, and since policy == 0 == GPM_WARNING_TIME,
we go into the body of the if statement, and begin checking status->remaining_time : clearly wrong.

 90 /* get from gconf */
 91 if (policy == GPM_WARNING_AUTO) {
 92 policy = warning->priv->use_time;
 93 }
 94
 95 /* this is a CSR mouse */
 96 if (status->design_charge == 7) {
--- SNIP ---
102 } else if (policy == GPM_WARNING_TIME) {
103 if (status->remaining_time <= 0) {
104 type = GPM_WARNING_NONE;
105 } else if (status->remaining_time <= warning->priv->action_time) {
106 type = GPM_WARNING_ACTION;
107 } else if (status->remaining_time <= warning->priv->critical_time) {
108 type = GPM_WARNING_CRITICAL;
109 } else if (status->remaining_time <= warning->priv->very_low_time) {
110 type = GPM_WARNING_VERY_LOW;
111 } else if (status->remaining_time <= warning->priv->low_time) {
112 type = GPM_WARNING_LOW;
113 }
114 } else {
115 if (status->percentage_charge <= 0) {

I don't know the Gnome style conventions, but I think that the most readable fix would be to change

policy = warning->priv->use_time;

to

if ( warning->priv->use_time )
  policy = GPM_WARNING_TIME;
else
  policy = GPM_WARNING_PERCENTAGE;

Revision history for this message
dennis (dwavomba) wrote :

I realized the same thing with gpm on ubuntu and archlinux. So I wrote my own patch to ensure explicit checking of the gconf use_time_for_policy in gpm-manager.c. The patch is attached. The devs can pick it up or you could apply it on your own

Revision history for this message
Caroline Ford (secretlondon) wrote :

is this still a problem in Hardy?

Changed in gnome-power-manager:
status: New → Incomplete
Revision history for this message
Pedro Villavicencio (pedro) wrote :

We are closing this bug report because it lacks the information we need to investigate the problem, as described in the previous comments. Please reopen it if you can give us the missing information, and don't hesitate to submit bug reports in the future. To reopen the bug report you can click on the current status, under the Status column, and change the Status back to "New". Thanks again!.

Changed in gnome-power-manager:
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.