1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-27 04:32:55 +00:00

Bugfix: ac-adapter is sometimes called ADP1 in sysfs instead of AC

This commit is contained in:
Nikolas Garofil 2010-04-12 12:33:24 +02:00
parent 15326c502c
commit a6b43da875
2 changed files with 10 additions and 5 deletions

View File

@ -183,9 +183,6 @@ struct text_object *construct_text_object(char *s, const char *arg, long
NORM_ERR("acpiacadapter: arg is only used on linux");
#endif
}
if(! obj->data.opaque)
obj->data.opaque = strdup("AC");
obj->callbacks.print = &print_acpiacadapter;
obj->callbacks.free = &gen_free_opaque;
#endif /* !__OpenBSD__ */

View File

@ -1353,6 +1353,8 @@ void get_acpi_fan(char *p_client_buffer, size_t client_buffer_size)
Update: it seems the folder name is hardware-dependent. We add an aditional adapter
argument, specifying the folder name.
Update: on some systems it's /sys/class/power_supply/ADP1 instead of /sys/class/power_supply/AC
*/
void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size, const char *adapter)
@ -1361,14 +1363,20 @@ void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size, const
char buf[256];
char buf2[256];
struct stat sb;
FILE *fp;
if (!p_client_buffer || client_buffer_size <= 0) {
return;
}
snprintf(buf2, sizeof(buf2), "%s/%s/uevent", SYSFS_AC_ADAPTER_DIR, adapter);
fp = open_file(buf2, &rep);
if(adapter)
snprintf(buf2, sizeof(buf2), "%s/%s/uevent", SYSFS_AC_ADAPTER_DIR, adapter);
else{
snprintf(buf2, sizeof(buf2), "%s/AC/uevent", SYSFS_AC_ADAPTER_DIR);
if(stat(buf2, &sb) == -1) snprintf(buf2, sizeof(buf2), "%s/ADP1/uevent", SYSFS_AC_ADAPTER_DIR);
}
if(stat(buf2, &sb) == 0) fp = open_file(buf2, &rep); else fp = 0;
if (fp) {
/* sysfs processing */
while (!feof(fp)) {