Skip to content

Commit

Permalink
finally formatting fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
supertick committed Apr 27, 2024
1 parent 58d0889 commit 35704ac
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/main/java/org/myrobotlab/service/Runtime.java
Original file line number Diff line number Diff line change
Expand Up @@ -3684,24 +3684,26 @@ public static Double getBatteryLevel() {
}

} else if (platform.isLinux()) {
// TODO This is incorrect, will not work when unplugged
// and acpitool output is different than expected,
// at least on Ubuntu 22.04 - consider oshi library
String ret = Runtime.execute("acpi");
int pos0 = ret.indexOf("%");

if (pos0 != -1) {
int pos1 = ret.lastIndexOf(" ", pos0);
// int pos1 = ret.indexOf("%", pos0);
String dble = ret.substring(pos1, pos0).trim();
try {
r = Double.parseDouble(dble);
} catch (Exception e) {
log.error("no Battery detected by system");
// TODO This is incorrect, will not work when unplugged
// and acpitool output is different than expected,
// at least on Ubuntu 22.04 - consider oshi library
if (FileIO.isExecutableAvailable("acpi")) {
String ret = Runtime.execute("acpi");
int pos0 = ret.indexOf("%");

if (pos0 != -1) {
int pos1 = ret.lastIndexOf(" ", pos0);
// int pos1 = ret.indexOf("%", pos0);
String dble = ret.substring(pos1, pos0).trim();
try {
r = Double.parseDouble(dble);
} catch (Exception e) {
log.error("no Battery detected by system");
}
return r;
}
return r;
log.info(ret);
}
log.info(ret);
} else if (platform.isMac()) {
String ret = Runtime.execute("pmset -g batt");
int pos0 = ret.indexOf("Battery-0");
Expand Down

0 comments on commit 35704ac

Please sign in to comment.