1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-14 11:33:14 +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:45:10 +02:00
parent 9a334e4462
commit 99eeeae6d0
3 changed files with 12 additions and 6 deletions

View File

@ -7,8 +7,8 @@
<option>(adapter)</option> <option>(adapter)</option>
</term> </term>
<listitem>ACPI ac adapter state. On linux, the adapter option specifies the <listitem>ACPI ac adapter state. On linux, the adapter option specifies the
subfolder of /sys/class/power_supply containing the state information (defaults subfolder of /sys/class/power_supply containing the state information (tries "AC"
to "AC"). Other systems ignore it. and "ADP1" if there is no argument given). Non-linux systems ignore it.
<para /></listitem> <para /></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>

View File

@ -171,8 +171,6 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
NORM_ERR("acpiacadapter: arg is only used on linux"); NORM_ERR("acpiacadapter: arg is only used on linux");
#endif #endif
} }
if(! obj->data.opaque)
obj->data.opaque = strdup("AC");
#endif /* !__OpenBSD__ */ #endif /* !__OpenBSD__ */
END OBJ(freq, 0) END OBJ(freq, 0)
get_cpu_count(); get_cpu_count();

View File

@ -1336,6 +1336,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 Update: it seems the folder name is hardware-dependent. We add an aditional adapter
argument, specifying the folder name. 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) void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size, const char *adapter)
@ -1344,14 +1346,20 @@ void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size, const
char buf[256]; char buf[256];
char buf2[256]; char buf2[256];
struct stat sb;
FILE *fp; FILE *fp;
if (!p_client_buffer || client_buffer_size <= 0) { if (!p_client_buffer || client_buffer_size <= 0) {
return; return;
} }
if(adapter)
snprintf(buf2, sizeof(buf2), "%s/%s/uevent", SYSFS_AC_ADAPTER_DIR, adapter); snprintf(buf2, sizeof(buf2), "%s/%s/uevent", SYSFS_AC_ADAPTER_DIR, adapter);
fp = open_file(buf2, &rep); 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) { if (fp) {
/* sysfs processing */ /* sysfs processing */
while (!feof(fp)) { while (!feof(fp)) {