Public bug reported:

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;

** Affects: gnome-power-manager (Ubuntu)
     Importance: Undecided
         Status: Unconfirmed


** Tags: action battery percentage time

-- 
g-p-m does not allow using battery percentage for policy in feisty
https://bugs.launchpad.net/bugs/113244
You received this bug notification because you are a member of Ubuntu
Bugs, which is the bug contact for Ubuntu.

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to