Skip to content

Commit 1c1b748

Browse files
author
WolfTech Innovations
authored
Merge branch 'fastfetch-cli:dev' into dev
2 parents 7c68280 + 46f920a commit 1c1b748

File tree

20 files changed

+346
-28
lines changed

20 files changed

+346
-28
lines changed

CMakeLists.txt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,13 +1132,13 @@ elseif(Haiku)
11321132
src/detection/chassis/chassis_windows.c
11331133
src/detection/cpu/cpu_haiku.c
11341134
src/detection/cpucache/cpucache_shared.c
1135-
src/detection/cpuusage/cpuusage_nosupport.c
1135+
src/detection/cpuusage/cpuusage_haiku.c
11361136
src/detection/cursor/cursor_nosupport.c
1137-
src/detection/bluetooth/bluetooth_nosupport.c
1137+
src/detection/bluetooth/bluetooth_haiku.cpp
11381138
src/detection/bluetoothradio/bluetoothradio_nosupport.c
11391139
src/detection/disk/disk_haiku.cpp
11401140
src/detection/dns/dns_linux.c
1141-
src/detection/physicaldisk/physicaldisk_nosupport.c
1141+
src/detection/physicaldisk/physicaldisk_haiku.c
11421142
src/detection/physicalmemory/physicalmemory_linux.c
11431143
src/detection/diskio/diskio_nosupport.c
11441144
src/detection/displayserver/displayserver_haiku.cpp
@@ -1149,18 +1149,18 @@ elseif(Haiku)
11491149
src/detection/host/host_windows.c
11501150
src/detection/icons/icons_nosupport.c
11511151
src/detection/initsystem/initsystem_haiku.cpp
1152-
src/detection/keyboard/keyboard_nosupport.c
1152+
src/detection/keyboard/keyboard_haiku.cpp
11531153
src/detection/libc/libc_nosupport.c
11541154
src/detection/lm/lm_nosupport.c
11551155
src/detection/loadavg/loadavg_nosupport.c
11561156
src/detection/locale/locale_linux.c
11571157
src/detection/localip/localip_linux.c
1158-
src/detection/gamepad/gamepad_nosupport.c
1158+
src/detection/gamepad/gamepad_haiku.cpp
11591159
src/detection/media/media_linux.c
11601160
src/detection/memory/memory_haiku.c
1161-
src/detection/mouse/mouse_nosupport.c
1162-
src/detection/netio/netio_nosupport.c
1163-
src/detection/opengl/opengl_linux.c
1161+
src/detection/mouse/mouse_haiku.cpp
1162+
src/detection/netio/netio_haiku.cpp
1163+
src/detection/opengl/opengl_haiku.cpp
11641164
src/detection/os/os_haiku.c
11651165
src/detection/packages/packages_haiku.c
11661166
src/detection/poweradapter/poweradapter_nosupport.c
@@ -1646,7 +1646,11 @@ elseif(ANDROID)
16461646
elseif(Haiku)
16471647
target_link_libraries(libfastfetch
16481648
PRIVATE "network"
1649+
PRIVATE "bnetapi"
16491650
PRIVATE "media"
1651+
PRIVATE "device"
1652+
PRIVATE "bluetooth"
1653+
PRIVATE "GL"
16501654
PRIVATE "be"
16511655
PRIVATE "gnu"
16521656
)

presets/all.jsonc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@
9090
"sound",
9191
"camera",
9292
"gamepad",
93+
"mouse",
94+
"keyboard",
9395
{
9496
"type": "weather",
9597
"timeout": 1000

presets/ci.jsonc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@
9292
"sound",
9393
"camera",
9494
"gamepad",
95+
"mouse",
96+
"keyboard",
9597
{
9698
"type": "weather",
9799
"timeout": 1000
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
extern "C" {
2+
#include "bluetooth.h"
3+
#include "common/io/io.h"
4+
}
5+
6+
#include <bluetooth/LocalDevice.h>
7+
8+
const char* ffDetectBluetooth(FF_MAYBE_UNUSED FFBluetoothOptions* options, FFlist* devices /* FFBluetoothResult */)
9+
{
10+
using namespace Bluetooth;
11+
FF_SUPPRESS_IO();
12+
13+
LocalDevice* dev = LocalDevice::GetLocalDevice();
14+
if (!dev) return NULL;
15+
16+
BString devClass;
17+
dev->GetDeviceClass().DumpDeviceClass(devClass);
18+
19+
FFBluetoothResult* device = (FFBluetoothResult*) ffListAdd(devices);
20+
ffStrbufInitS(&device->name, dev->GetFriendlyName());
21+
ffStrbufInitS(&device->address, bdaddrUtils::ToString(dev->GetBluetoothAddress()).String());
22+
ffStrbufInitS(&device->type, devClass.String());
23+
device->battery = 0;
24+
device->connected = true;
25+
26+
// TODO: more devices?
27+
28+
return NULL;
29+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include "fastfetch.h"
2+
#include "detection/cpuusage/cpuusage.h"
3+
#include "util/mallocHelper.h"
4+
5+
#include <OS.h>
6+
7+
const char* ffGetCpuUsageInfo(FFlist* cpuTimes)
8+
{
9+
system_info sysInfo;
10+
if (get_system_info(&sysInfo) != B_OK)
11+
return "get_system_info() failed";
12+
13+
FF_AUTO_FREE cpu_info* cpuInfo = malloc(sizeof(*cpuInfo) * sysInfo.cpu_count);
14+
if (get_cpu_info(0, sysInfo.cpu_count, cpuInfo) != B_OK)
15+
return "get_cpu_info() failed";
16+
17+
uint64_t uptime = (uint64_t) system_time();
18+
19+
for (uint32_t i = 0; i < sysInfo.cpu_count; ++i)
20+
{
21+
FFCpuUsageInfo* info = (FFCpuUsageInfo*) ffListAdd(cpuTimes);
22+
info->inUseAll = (uint64_t) cpuInfo[i].active_time;
23+
info->totalAll = uptime;
24+
}
25+
26+
return NULL;
27+
}

src/detection/disk/disk_haiku.cpp

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
11
extern "C"
22
{
33
#include "disk.h"
4+
#include "util/stringUtils.h"
45
}
56
#include <fs_info.h>
67
#include <Directory.h>
78
#include <Path.h>
89

9-
const char* ffDetectDisksImpl(FF_MAYBE_UNUSED FFDiskOptions* options, FF_MAYBE_UNUSED FFlist* disks)
10+
const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
1011
{
1112
int32 pos = 0;
1213

1314
for (dev_t dev; (dev = next_dev(&pos)) >= B_OK;)
1415
{
1516
fs_info fs;
16-
fs_stat_dev(dev, &fs);
17+
if (fs_stat_dev(dev, &fs) < -1) continue;
18+
19+
if (!ffStrStartsWith(fs.device_name, "/dev/")) continue; // physical disks only
20+
21+
node_ref node(fs.dev, fs.root);
22+
BDirectory dir(&node);
23+
BPath path(&dir);
24+
if (path.InitCheck() != B_OK) continue;
25+
26+
if (__builtin_expect(options->folders.length, 0))
27+
{
28+
if (!ffDiskMatchMountpoint(options, path.Path()))
29+
continue;
30+
}
1731

1832
FFDisk* disk = (FFDisk*) ffListAdd(disks);
1933

@@ -26,16 +40,7 @@ const char* ffDetectDisksImpl(FF_MAYBE_UNUSED FFDiskOptions* options, FF_MAYBE_U
2640
disk->filesUsed = (uint32_t) (disk->filesTotal - (uint64_t)fs.free_nodes);
2741

2842
ffStrbufInitS(&disk->mountFrom, fs.device_name);
29-
ffStrbufInit(&disk->mountpoint);
30-
{
31-
node_ref node(fs.dev, fs.root);
32-
BDirectory dir(&node);
33-
BPath path(&dir);
34-
if (path.InitCheck() == B_OK)
35-
ffStrbufSetS(&disk->mountpoint, path.Path());
36-
else
37-
ffStrbufSetStatic(&disk->mountpoint, "?");
38-
}
43+
ffStrbufInitS(&disk->mountpoint, path.Path());
3944
ffStrbufInitS(&disk->filesystem, fs.fsh_name);
4045
ffStrbufInitS(&disk->name, fs.volume_name);
4146
disk->type = FF_DISK_VOLUME_TYPE_NONE;
@@ -45,7 +50,12 @@ const char* ffDetectDisksImpl(FF_MAYBE_UNUSED FFDiskOptions* options, FF_MAYBE_U
4550
disk->type = (FFDiskVolumeType) (disk->type | FF_DISK_VOLUME_TYPE_READONLY_BIT);
4651
if (fs.flags & B_FS_IS_REMOVABLE)
4752
disk->type = (FFDiskVolumeType) (disk->type | FF_DISK_VOLUME_TYPE_EXTERNAL_BIT);
53+
if (disk->type == FF_DISK_VOLUME_TYPE_NONE) disk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
4854
disk->createTime = 0;
55+
56+
time_t crTime;
57+
if (dir.GetCreationTime(&crTime) == B_OK)
58+
disk->createTime = (uint64_t) crTime * 1000;
4959
}
50-
return 0;
60+
return NULL;
5161
}

src/detection/font/font_haiku.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
extern "C" {
2-
#include "common/font.h"
3-
#include "common/parsing.h"
42
#include "font.h"
53
}
64

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
extern "C" {
2+
#include "gamepad.h"
3+
}
4+
#include <Joystick.h>
5+
6+
const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */)
7+
{
8+
BJoystick js;
9+
for (int32 i = 0, n = js.CountDevices(); i < n; ++i)
10+
{
11+
char name[B_OS_NAME_LENGTH];
12+
if (js.GetDeviceName(i, name) == B_OK)
13+
{
14+
FFGamepadDevice* device = (FFGamepadDevice*) ffListAdd(devices);
15+
ffStrbufInit(&device->serial);
16+
ffStrbufInitS(&device->name, name);
17+
device->battery = 0;
18+
}
19+
}
20+
return NULL;
21+
}

src/detection/gpu/gpu_apple.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus)
115115
if(ffCfDictGetInt(properties, CFSTR("gpu-core-count"), &gpu->coreCount)) // For Apple
116116
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
117117

118-
gpu->coreUsage = 0.0/0.0;
118+
gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET;
119119
CFDictionaryRef perfStatistics = NULL;
120120
uint64_t vramUsed = 0, vramTotal = 0;
121121
if (ffCfDictGetDict(properties, CFSTR("PerformanceStatistics"), &perfStatistics) == NULL)

src/detection/gpu/gpu_general.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
3636
ffStrbufInit(&gpu->platformApi);
3737
gpu->temperature = FF_GPU_TEMP_UNSET;
3838
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
39+
gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET;
3940
gpu->type = FF_GPU_TYPE_UNKNOWN;
4041
gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
4142
gpu->deviceId = ((uint64_t) dev->domain << 6) | ((uint64_t) dev->bus << 4) | ((uint64_t) dev->dev << 2) | (uint64_t) dev->func;

0 commit comments

Comments
 (0)