From 2c45fa7254e13c0b76c6decaa71771a1771f86b4 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 19 Nov 2024 01:00:30 +0100 Subject: Support more laptops for power supply option --- src/Overlay.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Overlay.cpp b/src/Overlay.cpp index f4729e1..16495fc 100644 --- a/src/Overlay.cpp +++ b/src/Overlay.cpp @@ -294,12 +294,18 @@ namespace gsr { static std::string get_power_supply_online_filepath() { std::string result; - if(access("/sys/class/power_supply/ADP1/online", F_OK) == 0) - result = "/sys/class/power_supply/ADP1/online"; - else if(access("/sys/class/power_supply/AC/online", F_OK) == 0) - result = "/sys/class/power_supply/AC/online"; - else if(access("/sys/class/power_supply/ACAD/online", F_OK) == 0) - result = "/sys/class/power_supply/ACAD/online"; + const char *paths[] = { + "/sys/class/power_supply/ADP0/online", + "/sys/class/power_supply/ADP1/online", + "/sys/class/power_supply/AC/online", + "/sys/class/power_supply/ACAD/online" + }; + for(const char *power_supply_online_filepath : paths) { + if(access(power_supply_online_filepath, F_OK) == 0) { + result = power_supply_online_filepath; + break; + } + } return result; } -- cgit v1.2.3