Skip to content

Commit c53191a

Browse files
committed
Battery (Haiku): add stub file
1 parent 14aadd5 commit c53191a

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ elseif(Haiku)
11231123
src/common/netif/netif_haiku.c
11241124
src/common/networking_linux.c
11251125
src/common/processing_linux.c
1126-
src/detection/battery/battery_nosupport.c
1126+
src/detection/battery/battery_haiku.c
11271127
src/detection/bios/bios_nosupport.c
11281128
src/detection/board/board_nosupport.c
11291129
src/detection/bootmgr/bootmgr_nosupport.c
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "fastfetch.h"
2+
#include "battery.h"
3+
#include "common/io/io.h"
4+
#include "util/stringUtils.h"
5+
6+
void parseBattery(FFstrbuf* content, FFlist* results)
7+
{
8+
char* line = NULL;
9+
size_t n = 0;
10+
while (ffStrbufGetline(&line, &n, content))
11+
{
12+
13+
}
14+
}
15+
16+
const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
17+
{
18+
FF_AUTO_CLOSE_DIR DIR* dir = opendir("/dev/power/acpi_battery/");
19+
if (!dir) return "opendir(/dev/power/acpi_battery) failed";
20+
21+
FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate();
22+
struct dirent* entry;
23+
while ((entry = readdir(dir)))
24+
{
25+
if (entry->d_name[0] == '.') continue;
26+
if (!ffReadFileBufferRelative(dirfd(dir), entry->d_name, &content)) continue;
27+
parseBattery(&content, results);
28+
}
29+
30+
return "To be supported";
31+
}

0 commit comments

Comments
 (0)