mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-25 12:10:03 +00:00
battery probs
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@544 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
1d6a4ddde9
commit
fdb633ce95
@ -1,5 +1,8 @@
|
||||
# $Id$
|
||||
|
||||
2006-03-06
|
||||
* Fixed battery problems when charged
|
||||
|
||||
2006-03-05
|
||||
* Added patch to make $cpu stuff work on alpha (thanks Thomas Cort)
|
||||
http://bugs.gentoo.org/show_bug.cgi?id=122637#c3
|
||||
|
12
src/linux.c
12
src/linux.c
@ -1087,6 +1087,7 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat)
|
||||
{
|
||||
static int rep, rep2;
|
||||
char acpi_path[128];
|
||||
int design_capacity;
|
||||
snprintf(acpi_path, 127, ACPI_BATTERY_BASE_PATH "/%s/state", bat);
|
||||
|
||||
/* don't update battery too often */
|
||||
@ -1119,11 +1120,12 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat)
|
||||
char b[256];
|
||||
if (fgets(b, 256, fp) == NULL)
|
||||
break;
|
||||
|
||||
if (sscanf
|
||||
(b, "last full capacity: %d",
|
||||
&acpi_last_full) != 0)
|
||||
if (sscanf(b, "design capacity: %d", &design_capacity) != 0) {
|
||||
continue;
|
||||
}
|
||||
if (sscanf(b, "last full capacity: %d", &acpi_last_full) != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
@ -1188,7 +1190,7 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat)
|
||||
&& remaining_capacity != acpi_last_full)
|
||||
sprintf(last_battery_str, "charged %d%%",
|
||||
remaining_capacity * 100 /
|
||||
acpi_last_full);
|
||||
design_capacity);
|
||||
else
|
||||
strcpy(last_battery_str, "charged");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user