power: quick fix.
This commit is contained in:
parent
de6f8a3d99
commit
28bc182832
|
@ -528,15 +528,26 @@ system_power_state_get(power_t *power)
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
char *buf = file_contents("/sys/class/power_supply/AC/online");
|
static const char *found = NULL;
|
||||||
if (buf)
|
static const char *known[] = {
|
||||||
|
"/sys/class/power_supply/AC/online",
|
||||||
|
"/sys/class/power_supply/ACAD/online",
|
||||||
|
"/sys/class/power_supply/ADP0/online",
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 0; (!found) && (i < sizeof(known) / sizeof(char *)); i++)
|
||||||
{
|
{
|
||||||
power->have_ac = atoi(buf);
|
struct stat st;
|
||||||
free(buf);
|
if (stat(known[i], &st) == 0)
|
||||||
|
{
|
||||||
|
found = known[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (found)
|
||||||
{
|
{
|
||||||
char *buf = file_contents("/sys/class/power_supply/ACAD/online");
|
char *buf = file_contents(found);
|
||||||
if (buf)
|
if (buf)
|
||||||
{
|
{
|
||||||
power->have_ac = atoi(buf);
|
power->have_ac = atoi(buf);
|
||||||
|
|
Loading…
Reference in New Issue