summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlastair Poole <netstar@gmail.com>2021-08-10 21:29:21 +0100
committerAlastair Poole <netstar@gmail.com>2021-08-10 21:29:21 +0100
commit4a5e8507593f6a3302e166db8a7fbdcf87e29286 (patch)
tree173a9998b85c61e074d45cc27e72218ed7e5d185
parentb792e494d3c1258bd7d12b4e88504a36e6372c35 (diff)
power: quick fix.
This needs to do a proper lookup as per thermals etc...
-rw-r--r--src/bin/system/machine/sensors.x22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/bin/system/machine/sensors.x b/src/bin/system/machine/sensors.x
index 2cfda98..7d0d2d7 100644
--- a/src/bin/system/machine/sensors.x
+++ b/src/bin/system/machine/sensors.x
@@ -580,15 +580,25 @@ power_ac_present(void)
580 close(fd); 580 close(fd);
581 } 581 }
582#elif defined(__linux__) 582#elif defined(__linux__)
583 char *buf = file_contents("/sys/class/power_supply/AC/online"); 583 static const char *found = NULL;
584 if (buf) 584 static const char *known[] = {
585 "/sys/class/power_supply/AC/online",
586 "/sys/class/power_supply/ACAD/online",
587 "/sys/class/power_supply/ADP0/online",
588 };
589
590 for (int i = 0; (!found) && (i < sizeof(known) / sizeof(char *)); i++)
585 { 591 {
586 have_ac = atoi(buf); 592 if (ecore_file_exists(known[i]))
587 free(buf); 593 {
594 found = known[i];
595 break;
596 }
588 } 597 }
589 else 598
599 if (found)
590 { 600 {
591 buf = file_contents("/sys/class/power_supply/ACAD/online"); 601 char *buf = file_contents(found);
592 if (buf) 602 if (buf)
593 { 603 {
594 have_ac = atoi(buf); 604 have_ac = atoi(buf);