-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fastfetch-cli:dev' into dev
- Loading branch information
Showing
20 changed files
with
346 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,8 @@ | |
"sound", | ||
"camera", | ||
"gamepad", | ||
"mouse", | ||
"keyboard", | ||
{ | ||
"type": "weather", | ||
"timeout": 1000 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,8 @@ | |
"sound", | ||
"camera", | ||
"gamepad", | ||
"mouse", | ||
"keyboard", | ||
{ | ||
"type": "weather", | ||
"timeout": 1000 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
extern "C" { | ||
#include "bluetooth.h" | ||
#include "common/io/io.h" | ||
} | ||
|
||
#include <bluetooth/LocalDevice.h> | ||
|
||
const char* ffDetectBluetooth(FF_MAYBE_UNUSED FFBluetoothOptions* options, FFlist* devices /* FFBluetoothResult */) | ||
{ | ||
using namespace Bluetooth; | ||
FF_SUPPRESS_IO(); | ||
|
||
LocalDevice* dev = LocalDevice::GetLocalDevice(); | ||
if (!dev) return NULL; | ||
|
||
BString devClass; | ||
dev->GetDeviceClass().DumpDeviceClass(devClass); | ||
|
||
FFBluetoothResult* device = (FFBluetoothResult*) ffListAdd(devices); | ||
ffStrbufInitS(&device->name, dev->GetFriendlyName()); | ||
ffStrbufInitS(&device->address, bdaddrUtils::ToString(dev->GetBluetoothAddress()).String()); | ||
ffStrbufInitS(&device->type, devClass.String()); | ||
device->battery = 0; | ||
device->connected = true; | ||
|
||
// TODO: more devices? | ||
|
||
return NULL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "fastfetch.h" | ||
#include "detection/cpuusage/cpuusage.h" | ||
#include "util/mallocHelper.h" | ||
|
||
#include <OS.h> | ||
|
||
const char* ffGetCpuUsageInfo(FFlist* cpuTimes) | ||
{ | ||
system_info sysInfo; | ||
if (get_system_info(&sysInfo) != B_OK) | ||
return "get_system_info() failed"; | ||
|
||
FF_AUTO_FREE cpu_info* cpuInfo = malloc(sizeof(*cpuInfo) * sysInfo.cpu_count); | ||
if (get_cpu_info(0, sysInfo.cpu_count, cpuInfo) != B_OK) | ||
return "get_cpu_info() failed"; | ||
|
||
uint64_t uptime = (uint64_t) system_time(); | ||
|
||
for (uint32_t i = 0; i < sysInfo.cpu_count; ++i) | ||
{ | ||
FFCpuUsageInfo* info = (FFCpuUsageInfo*) ffListAdd(cpuTimes); | ||
info->inUseAll = (uint64_t) cpuInfo[i].active_time; | ||
info->totalAll = uptime; | ||
} | ||
|
||
return NULL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
extern "C" { | ||
#include "common/font.h" | ||
#include "common/parsing.h" | ||
#include "font.h" | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
extern "C" { | ||
#include "gamepad.h" | ||
} | ||
#include <Joystick.h> | ||
|
||
const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) | ||
{ | ||
BJoystick js; | ||
for (int32 i = 0, n = js.CountDevices(); i < n; ++i) | ||
{ | ||
char name[B_OS_NAME_LENGTH]; | ||
if (js.GetDeviceName(i, name) == B_OK) | ||
{ | ||
FFGamepadDevice* device = (FFGamepadDevice*) ffListAdd(devices); | ||
ffStrbufInit(&device->serial); | ||
ffStrbufInitS(&device->name, name); | ||
device->battery = 0; | ||
} | ||
} | ||
return NULL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
extern "C" { | ||
#include "keyboard.h" | ||
} | ||
|
||
#include <interface/Input.h> | ||
#include <support/List.h> | ||
|
||
const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) | ||
{ | ||
BList list; | ||
|
||
if (get_input_devices(&list) != B_OK) | ||
return "get_input_devices() failed"; | ||
|
||
for (int32 i = 0, n = list.CountItems(); i < n; i++) | ||
{ | ||
BInputDevice *device = (BInputDevice *) list.ItemAt(i); | ||
if (device->Type() != B_KEYBOARD_DEVICE || !device->IsRunning()) | ||
continue; | ||
|
||
FFKeyboardDevice* item = (FFKeyboardDevice*) ffListAdd(devices); | ||
ffStrbufInit(&item->serial); | ||
ffStrbufInitS(&item->name, device->Name()); | ||
} | ||
|
||
return NULL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
extern "C" { | ||
#include "mouse.h" | ||
} | ||
|
||
#include <interface/Input.h> | ||
#include <support/List.h> | ||
|
||
const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) | ||
{ | ||
BList list; | ||
|
||
if (get_input_devices(&list) != B_OK) | ||
return "get_input_devices() failed"; | ||
|
||
for (int32 i = 0, n = list.CountItems(); i < n; i++) | ||
{ | ||
BInputDevice *device = (BInputDevice *) list.ItemAt(i); | ||
if (device->Type() != B_POINTING_DEVICE || !device->IsRunning()) | ||
continue; | ||
|
||
FFMouseDevice* item = (FFMouseDevice*) ffListAdd(devices); | ||
ffStrbufInit(&item->serial); | ||
ffStrbufInitS(&item->name, device->Name()); | ||
} | ||
|
||
return NULL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
extern "C" { | ||
#include "netio.h" | ||
#include "common/netif/netif.h" | ||
} | ||
|
||
#include <NetworkInterface.h> | ||
#include <NetworkRoster.h> | ||
|
||
const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) | ||
{ | ||
BNetworkRoster& roster = BNetworkRoster::Default(); | ||
|
||
BNetworkInterface interface; | ||
uint32 cookie = 0; | ||
|
||
uint32_t defaultRouteIfIndex = ffNetifGetDefaultRouteIfIndex(); | ||
|
||
while (roster.GetNextInterface(&cookie, interface) == B_OK) | ||
{ | ||
if (!interface.Exists()) | ||
continue; | ||
|
||
bool defaultRoute = interface.Index() == defaultRouteIfIndex; | ||
if (options->defaultRouteOnly && !defaultRoute) | ||
continue; | ||
|
||
if (options->namePrefix.length && strncmp(interface.Name(), options->namePrefix.chars, options->namePrefix.length) != 0) | ||
continue; | ||
|
||
ifreq_stats stats = {}; | ||
if (interface.GetStats(stats) != B_OK) continue; | ||
|
||
FFNetIOResult* counters = (FFNetIOResult*) ffListAdd(result); | ||
*counters = (FFNetIOResult) { | ||
.name = ffStrbufCreateS(interface.Name()), | ||
.defaultRoute = defaultRoute, | ||
.txBytes = stats.send.bytes, | ||
.rxBytes = stats.receive.bytes, | ||
.txPackets = stats.send.packets, | ||
.rxPackets = stats.receive.packets, | ||
.rxErrors = stats.receive.errors, | ||
.txErrors = stats.send.errors, | ||
.rxDrops = stats.receive.dropped, | ||
.txDrops = stats.send.dropped | ||
}; | ||
} | ||
|
||
return NULL; | ||
} |
Oops, something went wrong.