Skip to content

Commit 886bde4

Browse files
committed
Battery (Linux): checks if battery's present before parsing
1 parent 254fb82 commit 886bde4

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/detection/battery/battery_linux.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
static bool parseBattery(int dfd, const char* id, FFBatteryOptions* options, FFlist* results, bool* acConnected) {
1313
FF_STRBUF_AUTO_DESTROY tmpBuffer = ffStrbufCreate();
1414

15+
{
16+
char present = '\0';
17+
if (ffReadFileDataRelative(dfd, "present", 1, &present) && present == '0') {
18+
FF_DEBUG("Battery \"%s\": Not present", id);
19+
return false;
20+
}
21+
}
22+
1523
// type must exist
1624
if (!ffReadFileBufferRelative(dfd, "type", &tmpBuffer)) {
1725
FF_DEBUG("Battery \"%s\": No type file", id);

0 commit comments

Comments
 (0)