diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b8c32ef8..9570926f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1123,7 +1123,7 @@ elseif(Haiku) src/common/netif/netif_haiku.c src/common/networking_linux.c src/common/processing_linux.c - src/detection/battery/battery_nosupport.c + src/detection/battery/battery_haiku.c src/detection/bios/bios_nosupport.c src/detection/board/board_nosupport.c src/detection/bootmgr/bootmgr_nosupport.c diff --git a/src/detection/battery/battery_haiku.c b/src/detection/battery/battery_haiku.c new file mode 100644 index 000000000..abd10b594 --- /dev/null +++ b/src/detection/battery/battery_haiku.c @@ -0,0 +1,31 @@ +#include "fastfetch.h" +#include "battery.h" +#include "common/io/io.h" +#include "util/stringUtils.h" + +void parseBattery(FFstrbuf* content, FFlist* results) +{ + char* line = NULL; + size_t n = 0; + while (ffStrbufGetline(&line, &n, content)) + { + + } +} + +const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) +{ + FF_AUTO_CLOSE_DIR DIR* dir = opendir("/dev/power/acpi_battery/"); + if (!dir) return "opendir(/dev/power/acpi_battery) failed"; + + FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate(); + struct dirent* entry; + while ((entry = readdir(dir))) + { + if (entry->d_name[0] == '.') continue; + if (!ffReadFileBufferRelative(dirfd(dir), entry->d_name, &content)) continue; + parseBattery(&content, results); + } + + return "To be supported"; +}