Skip to content

Commit 4dc5033

Browse files
committed
PowerAdapter (Linux): checks if the device is present
1 parent b360339 commit 4dc5033

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/detection/battery/battery_linux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static bool parseBattery(int dfd, const char* id, FFBatteryOptions* options, FFl
4848
ffStrbufTrimRightSpace(&tmpBuffer);
4949

5050
FF_DEBUG("Battery \"%s\": Scope is \"%s\"", id, tmpBuffer.chars);
51-
if (ffStrbufIgnCaseEqualS(&tmpBuffer, "Device")) {
51+
if (ffStrbufEqualS(&tmpBuffer, "Device")) {
5252
return false;
5353
}
5454
}

src/detection/poweradapter/poweradapter_linux.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,29 @@
99
static void parsePowerAdapter(int dfd, const char* id, FFlist* results) {
1010
FF_STRBUF_AUTO_DESTROY tmpBuffer = ffStrbufCreate();
1111

12+
{
13+
char present = '\0';
14+
if (ffReadFileDataRelative(dfd, "present", 1, &present) && present == '0') {
15+
return;
16+
}
17+
}
18+
1219
// type must exist and be "Mains"
1320
if (ffReadFileBufferRelative(dfd, "type", &tmpBuffer)) {
1421
ffStrbufTrimRightSpace(&tmpBuffer);
1522
}
1623

17-
if (!ffStrbufIgnCaseEqualS(&tmpBuffer, "Mains")) {
24+
if (!ffStrbufEqualS(&tmpBuffer, "Mains")) {
1825
return;
1926
}
2027

2128
// scope may not exist or must not be "Device" (?)
2229
if (ffReadFileBufferRelative(dfd, "scope", &tmpBuffer)) {
2330
ffStrbufTrimRightSpace(&tmpBuffer);
24-
}
2531

26-
if (ffStrbufIgnCaseEqualS(&tmpBuffer, "Device")) {
27-
return;
32+
if (ffStrbufEqualS(&tmpBuffer, "Device")) {
33+
return;
34+
}
2835
}
2936

3037
char online = '\0';

0 commit comments

Comments
 (0)