My first
I made my first submission to an open source project! (Well, I attached the patch to Novell’s bugzilla where I had filled the bug.)
My laptop does not report back the rate the battery is being depleted correctly. The Gnome-Applet, Battery Charge Monitor, reports in a mouse over that the time remaining is unknown. However, when the low battery warning comes up, it says that there are -1 minutes of battery remaining.
Here is how B-C-M does its calculations
From acpi-linux.c
407 remain += read_long (hash, “remaining capacity”);
408 rate += read_long (hash, “present rate”);
409 g_hash_table_destroy (hash);
Line 408 reads the present rate from /proc/acpi/battery/BAT1/state. (BAT1 is my battery.)
The present rate of discharge for my battery is always 0 mA. Which is wrong.
A little farther down in the same file
422 if (rate && !charging)
423 apminfo->battery_time = (int) (remain/(float)rate * 60);
424 else if (rate && charging)
425 apminfo->battery_time = (int) ((acpiinfo->max_capacity-remain)/(float)rate * 60);
426 else
427 apminfo->battery_time = -1;
Since my rate is always 0…..I fallout at the end: battery_time = -1.
From battstat_applet.c
514 remaining = g_strdup_printf( ngettext(
515 ”You have %d minute of battery power “
516 ”remaining (%d%% of the total capacity).”,
517 ”You have %d minutes of battery power “
518 ”remaining (%d%% of the total capacity).”,
519 info->minutes ),
520 info->minutes,info->percent );
The above prints part (The offending part) of the text that prints in the low battery warning. info is the apminfo structure. So info->minutes for me is always -1. How to fix?
A simple if statement around the above:
514 if( info->minutes >= 0 )
515 remaining = g_strdup_printf( ngettext(
516 ”You have %d minute of battery power “
517 ”remaining (%d%% of the total capacity).”,
518 ”You have %d minutes of battery power “
519 ”remaining (%d%% of the total capacity).”,
520 info->minutes ),
521 info->minutes,info->percent );
522 else
523 remaining = g_strdup_printf( “You have unknown minutes of battery power “
524 ”remaining (%d%% of the total capacity).”,
525 info->percent );
Now I get the else…I am not too sure of the language. But I wanted to keep it similar to what is currently working other places. Now I think I am suppose to submit it to the mailing list…..?