1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-18 02:55:12 +00:00

Add check for battery not being present

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@674 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Brenden Matthews 2006-06-22 04:08:02 +00:00
parent 2783fa94a9
commit 2943179494

View File

@ -1217,6 +1217,7 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat)
int present_rate = -1;
int remaining_capacity = -1;
char charging_state[64];
char present[4];
/* read last full capacity if it's zero */
if (acpi_last_full == 0) {
@ -1250,7 +1251,9 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat)
break;
/* let's just hope units are ok */
if (buf[0] == 'c')
if (buf[0] == 'p') {
sscanf(buf, "present: %4s", present);
} else if (buf[0] == 'c')
sscanf(buf, "charging state: %63s",
charging_state);
else if (buf[0] == 'p')
@ -1261,8 +1264,12 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat)
&remaining_capacity);
}
/* not present */
if (strcmp(present, "no") == 0) {
strncpy(last_battery_str, "not present", 64);
}
/* charging */
if (strcmp(charging_state, "charging") == 0) {
else if (strcmp(charging_state, "charging") == 0) {
if (acpi_last_full != 0 && present_rate > 0) {
strncpy(last_battery_str, "charging ", 64);
format_seconds(last_battery_str + 9,