mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 10:22:12 +02:00
Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5b001d6bd6 | |||
| 1b52029fce | |||
| 2176ea2937 | |||
| ac2266c72f | |||
| 0dc40a2632 | |||
| ca975f8e81 | |||
| c4c6fe6668 | |||
| 0a00f5721e | |||
| 69f180beea | |||
| 0e9cdf75b5 | |||
| 7d7e219c0a | |||
| 4937ccfa81 | |||
| d0d29c163b | |||
| 901e0eb177 | |||
| 87446e6eef | |||
| bfaa73a2c7 | |||
| 373e288d03 | |||
| 82170ceab0 | |||
| 009a7888b5 | |||
| ab1a11c9fa | |||
| 68746275f8 | |||
| 491cfb94b6 | |||
| 79c8919431 | |||
| e98afa8315 | |||
| 86783c033b | |||
| f01944de41 | |||
| ebfdeef25c | |||
| 9a36d63d18 | |||
| e45ff546ed | |||
| 2700390371 | |||
| 5c01685d69 | |||
| d897472572 | |||
| 8410a66277 | |||
| 856d229b36 | |||
| b33692aa7d | |||
| e90c5cb241 | |||
| 03cd283755 |
@@ -452,7 +452,7 @@ jobs:
|
||||
version: '7.5'
|
||||
run: |
|
||||
uname -a
|
||||
sudo pkg_add -r cmake git pkgconf wayland vulkan-headers vulkan-loader glib2 dconf dbus sqlite3 xfconf imagemagick chafa pulseaudio py3-requests
|
||||
sudo pkg_add -r cmake git pkgconf wayland vulkan-headers vulkan-loader glib2 dconf dbus sqlite3 xfconf imagemagick chafa pulseaudio hwdata py3-requests
|
||||
cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=ON .
|
||||
cmake --build . --target package --verbose -j4
|
||||
./fastfetch --list-features
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
# 2.32.0
|
||||
|
||||
Bugfixes:
|
||||
* Fix `pci.ids` file location on OpenBSD (GPU, OpenBSD)
|
||||
* It's normally unused because enumerating PCI devices on OpenBSD requires root privileges
|
||||
* Fix bssid formatting (Wifi, Linux)
|
||||
* Fix Linux Lite distro detection (#1434, OS, Linux)
|
||||
* Suppress XE driver warnings from Mesa (#1435, OpenGL, Linux)
|
||||
* Fix format parameter name (#1443, Version)
|
||||
* Don't report useless information when Wifi is disabled (Wifi, FreeBSD)
|
||||
* Currently there are issues when the SSID contains whitespaces. More fixes are expected in the future.
|
||||
* Always use physical size reported by X11 server to avoid inconsistent results (#1444, Display, Linux)
|
||||
|
||||
Features:
|
||||
* Randomly select one if the logo source expands to multiple files (#1426, Logo)
|
||||
* Report mac product name when running Linux in MacBook (Host, Linux / FreeBSD)
|
||||
* Use screen size reported in DTD if make sense (Display)
|
||||
* Detect Virtualized Apple Silicon CPUs (CPU, Linux)
|
||||
* Add detection support for fvwm and ctwm (WM, OpenBSD / NetBSD)
|
||||
* Add Armbian-unofficial detection (OS, Linux)
|
||||
* Prefer surfaceless display when connect EGL (OpenGL)
|
||||
* Improve accuracy of WM detection on FreeBSD (WM, FreeBSD)
|
||||
* Add ratpoison window manager (WM, Linux)
|
||||
|
||||
Logo:
|
||||
* Update Linux Lite
|
||||
* Add Serpent OS
|
||||
* Add Ultramarine Small
|
||||
* Update Debian
|
||||
|
||||
# 2.31.0
|
||||
|
||||
Bugfixes:
|
||||
|
||||
+5
-1
@@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url
|
||||
|
||||
project(fastfetch
|
||||
VERSION 2.31.0
|
||||
VERSION 2.32.0
|
||||
LANGUAGES C
|
||||
DESCRIPTION "Fast neofetch-like system information tool"
|
||||
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"
|
||||
@@ -502,6 +502,7 @@ if(LINUX)
|
||||
src/detection/gpu/gpu_pci.c
|
||||
src/detection/gtk_qt/gtk.c
|
||||
src/detection/host/host_linux.c
|
||||
src/detection/host/host_mac.c
|
||||
src/detection/icons/icons_linux.c
|
||||
src/detection/initsystem/initsystem_linux.c
|
||||
src/detection/keyboard/keyboard_linux.c
|
||||
@@ -649,6 +650,7 @@ elseif(FreeBSD)
|
||||
src/detection/gpu/gpu_pci.c
|
||||
src/detection/gtk_qt/gtk.c
|
||||
src/detection/host/host_bsd.c
|
||||
src/detection/host/host_mac.c
|
||||
src/detection/lm/lm_linux.c
|
||||
src/detection/icons/icons_linux.c
|
||||
src/detection/initsystem/initsystem_linux.c
|
||||
@@ -881,6 +883,7 @@ elseif(APPLE)
|
||||
src/detection/gpu/gpu_apple.c
|
||||
src/detection/gpu/gpu_apple.m
|
||||
src/detection/host/host_apple.c
|
||||
src/detection/host/host_mac.c
|
||||
src/detection/icons/icons_nosupport.c
|
||||
src/detection/initsystem/initsystem_linux.c
|
||||
src/detection/keyboard/keyboard_apple.c
|
||||
@@ -949,6 +952,7 @@ elseif(WIN32)
|
||||
src/detection/dns/dns_windows.c
|
||||
src/detection/font/font_windows.c
|
||||
src/detection/gpu/gpu_windows.c
|
||||
src/detection/host/host_mac.c
|
||||
src/detection/host/host_windows.c
|
||||
src/detection/icons/icons_windows.c
|
||||
src/detection/initsystem/initsystem_nosupport.c
|
||||
|
||||
Vendored
+6
@@ -1,3 +1,9 @@
|
||||
fastfetch (2.31.0) jammy; urgency=medium
|
||||
|
||||
* Update to 2.31.0
|
||||
|
||||
-- Carter Li <zhangsongcui@live.cn> Wed, 04 Dec 2024 08:41:40 +0800
|
||||
|
||||
fastfetch (2.30.1) jammy; urgency=medium
|
||||
|
||||
* Update to 2.30.1
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
fastfetch_2.30.1_source.buildinfo universe/utils optional
|
||||
fastfetch_2.31.0_source.buildinfo universe/utils optional
|
||||
|
||||
+1406
-243
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -54,7 +54,7 @@ optionSection = r"""
|
||||
Parsing is not case sensitive. E.g. \fB--logo-type\fR is
|
||||
equal to \fB--LOGO-TYPE\fR.
|
||||
|
||||
If a value is between square brakets, it is optional.
|
||||
If a value is between square brackets, it is optional.
|
||||
An optional boolean value defaults to true if not specified.
|
||||
|
||||
More detailed help messages for each options can be printed
|
||||
|
||||
+2
-4
@@ -42,7 +42,5 @@ typedef struct FFformatarg
|
||||
|
||||
void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg);
|
||||
void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t numArgs, const FFformatarg* arguments);
|
||||
#define FF_PARSE_FORMAT_STRING_CHECKED(buffer, formatstr, numArgs, arguments) do {\
|
||||
static_assert(sizeof(arguments) / sizeof(*arguments) == (numArgs), "Invalid number of format arguments");\
|
||||
ffParseFormatString((buffer), (formatstr), (numArgs), (arguments));\
|
||||
} while (0)
|
||||
#define FF_PARSE_FORMAT_STRING_CHECKED(buffer, formatstr, arguments) \
|
||||
ffParseFormatString((buffer), (formatstr), sizeof(arguments) / sizeof(*arguments), (arguments));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "io.h"
|
||||
#include "fastfetch.h"
|
||||
#include "util/stringUtils.h"
|
||||
#include "common/time.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
@@ -145,10 +146,10 @@ bool ffPathExpandEnv(FF_MAYBE_UNUSED const char* in, FF_MAYBE_UNUSED FFstrbuf* o
|
||||
if (wordexp(in, &exp, 0) != 0)
|
||||
return false;
|
||||
|
||||
if (exp.we_wordc == 1)
|
||||
if (exp.we_wordc >= 1)
|
||||
{
|
||||
result = true;
|
||||
ffStrbufSetS(out, exp.we_wordv[0]);
|
||||
ffStrbufSetS(out, exp.we_wordv[exp.we_wordc > 1 ? ffTimeGetNow() % exp.we_wordc : 0]);
|
||||
}
|
||||
|
||||
wordfree(&exp);
|
||||
@@ -159,10 +160,10 @@ bool ffPathExpandEnv(FF_MAYBE_UNUSED const char* in, FF_MAYBE_UNUSED FFstrbuf* o
|
||||
if (glob(in, GLOB_NOSORT | GLOB_TILDE, NULL, &gb) != 0)
|
||||
return false;
|
||||
|
||||
if (gb.gl_matchc == 1)
|
||||
if (gb.gl_matchc >= 1)
|
||||
{
|
||||
result = true;
|
||||
ffStrbufSetS(out, gb.gl_pathv[0]);
|
||||
ffStrbufSetS(out, gb.gl_pathv[gb.gl_matchc > 1 ? ffTimeGetNow() % gb.gl_matchc : 0]);
|
||||
}
|
||||
|
||||
globfree(&gb);
|
||||
|
||||
+15
-23
@@ -6,6 +6,20 @@ struct yyjson_val;
|
||||
struct yyjson_mut_doc;
|
||||
struct yyjson_mut_val;
|
||||
|
||||
typedef struct FFModuleFormatArg
|
||||
{
|
||||
const char* desc;
|
||||
const char* name;
|
||||
} FFModuleFormatArg;
|
||||
|
||||
typedef struct FFModuleFormatArgList
|
||||
{
|
||||
FFModuleFormatArg* args;
|
||||
uint32_t count;
|
||||
} FFModuleFormatArgList;
|
||||
|
||||
#define FF_FORMAT_ARG_LIST(list) { .args = list, .count = sizeof(list) / sizeof(FFModuleFormatArg) }
|
||||
|
||||
// Must be the first field of FFModuleOptions
|
||||
typedef struct FFModuleBaseInfo
|
||||
{
|
||||
@@ -19,32 +33,10 @@ typedef struct FFModuleBaseInfo
|
||||
void (*parseJsonObject)(void* options, struct yyjson_val *module);
|
||||
void (*printModule)(void* options);
|
||||
void (*generateJsonResult)(void* options, struct yyjson_mut_doc* doc, struct yyjson_mut_val* module);
|
||||
void (*printHelpFormat)(void);
|
||||
void (*generateJsonConfig)(void* options, struct yyjson_mut_doc* doc, struct yyjson_mut_val* obj);
|
||||
FFModuleFormatArgList formatArgs;
|
||||
} FFModuleBaseInfo;
|
||||
|
||||
static inline void ffOptionInitModuleBaseInfo(
|
||||
FFModuleBaseInfo* baseInfo,
|
||||
const char* name,
|
||||
const char* description,
|
||||
void* parseCommandOptions, // bool (*const parseCommandOptions)(void* options, const char* key, const char* value)
|
||||
void* parseJsonObject, // void (*const parseJsonObject)(void* options, yyjson_val *module)
|
||||
void* printModule, // void (*const printModule)(void* options)
|
||||
void* generateJsonResult, // void (*const generateJsonResult)(void* options, yyjson_mut_doc* doc, yyjson_mut_val* obj)
|
||||
void (*printHelpFormat)(void),
|
||||
void* generateJsonConfig // void (*const generateJsonConfig)(void* options, yyjson_mut_doc* doc, yyjson_mut_val* obj)
|
||||
)
|
||||
{
|
||||
baseInfo->name = name;
|
||||
baseInfo->description = description;
|
||||
baseInfo->parseCommandOptions = (__typeof__(baseInfo->parseCommandOptions)) parseCommandOptions;
|
||||
baseInfo->parseJsonObject = (__typeof__(baseInfo->parseJsonObject)) parseJsonObject;
|
||||
baseInfo->printModule = (__typeof__(baseInfo->printModule)) printModule;
|
||||
baseInfo->generateJsonResult = (__typeof__(baseInfo->generateJsonResult)) generateJsonResult;
|
||||
baseInfo->printHelpFormat = printHelpFormat;
|
||||
baseInfo->generateJsonConfig = (__typeof__(baseInfo->generateJsonConfig)) generateJsonConfig;
|
||||
}
|
||||
|
||||
typedef enum __attribute__((__packed__)) FFModuleKeyType
|
||||
{
|
||||
FF_MODULE_KEY_TYPE_NONE = 0,
|
||||
|
||||
+1
-16
@@ -50,7 +50,7 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &moduleArgs->key, 2, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &moduleArgs->key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(moduleIndex, "index"),
|
||||
FF_FORMAT_ARG(moduleArgs->keyIcon, "icon"),
|
||||
}));
|
||||
@@ -148,18 +148,3 @@ void ffPrintCharTimes(char c, uint32_t times)
|
||||
if(remaining > 0)
|
||||
fwrite(str, 1, remaining, stdout);
|
||||
}
|
||||
|
||||
void ffPrintModuleFormatHelp(const char* name, const char* def, uint32_t numArgs, const char* args[])
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreateS(name);
|
||||
ffStrbufLowerCase(&buffer);
|
||||
printf("--%s-format:\n", buffer.chars);
|
||||
printf("Sets the format string for %s output.\n", name);
|
||||
puts("To see how a format string is constructed, take a look at \"fastfetch --help format\".");
|
||||
puts("The following values are passed:");
|
||||
|
||||
for(unsigned i = 0; i < numArgs; i++)
|
||||
printf(" {%u}: %s\n", i + 1, args[i]);
|
||||
|
||||
printf("The default is something similar to \"%s\".\n", def);
|
||||
}
|
||||
|
||||
+2
-10
@@ -14,16 +14,8 @@ typedef enum __attribute__((__packed__)) FFPrintType {
|
||||
|
||||
void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType);
|
||||
void ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, uint32_t numArgs, const FFformatarg* arguments);
|
||||
#define FF_PRINT_FORMAT_CHECKED(moduleName, moduleIndex, moduleArgs, printType, numArgs, arguments) do {\
|
||||
static_assert(sizeof(arguments) / sizeof(*arguments) == (numArgs), "Invalid number of format arguments");\
|
||||
ffPrintFormat((moduleName), (moduleIndex), (moduleArgs), (printType), (numArgs), (arguments));\
|
||||
} while (0)
|
||||
#define FF_PRINT_FORMAT_CHECKED(moduleName, moduleIndex, moduleArgs, printType, arguments) \
|
||||
ffPrintFormat((moduleName), (moduleIndex), (moduleArgs), (printType), (sizeof(arguments) / sizeof(*arguments)), (arguments));
|
||||
FF_C_PRINTF(5, 6) void ffPrintError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, const char* message, ...);
|
||||
void ffPrintColor(const FFstrbuf* colorValue);
|
||||
void ffPrintCharTimes(char c, uint32_t times);
|
||||
|
||||
void ffPrintModuleFormatHelp(const char* name, const char* def, uint32_t numArgs, const char* args[]);
|
||||
#define FF_PRINT_MODULE_FORMAT_HELP_CHECKED(moduleName, def, numArgs, args) do {\
|
||||
static_assert(sizeof(args) / sizeof(*args) == (numArgs), "Invalid number of format arguments");\
|
||||
ffPrintModuleFormatHelp((moduleName), (def), (numArgs), (args));\
|
||||
} while (0)
|
||||
|
||||
@@ -168,7 +168,8 @@ static const char* qcomPartId2name(uint32_t partId)
|
||||
{
|
||||
switch (partId)
|
||||
{
|
||||
case 0x001: return "Oryon";
|
||||
case 0x001: return "Oryon 1";
|
||||
case 0x002: return "Oryon 2";
|
||||
case 0x00f: return "Scorpion";
|
||||
case 0x02d: return "Scorpion";
|
||||
case 0x04d: return "Krait";
|
||||
@@ -262,6 +263,9 @@ static const char* applePartId2name(uint32_t partId)
|
||||
case 0x037: return "Everest-A16";
|
||||
case 0x038: return "Blizzard-M2-Max";
|
||||
case 0x039: return "Avalanche-M2-Max";
|
||||
case 0x046: return "Sawtooth-M11";
|
||||
case 0x048: return "Sawtooth-M3-Max";
|
||||
case 0x049: return "Everest-M3-Max";
|
||||
default: return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,28 +170,33 @@ static void detectArmName(FFstrbuf* cpuinfo, FFCPUResult* cpu, uint32_t implId)
|
||||
if (!ffStrStartsWith(line, "CPU part\t: ")) continue;
|
||||
uint32_t partId = (uint32_t) strtoul(line + strlen("CPU part\t: "), NULL, 16);
|
||||
const char* name = NULL;
|
||||
if (partId > 0) // Linux reports 0 for unknown CPUs
|
||||
switch (implId)
|
||||
{
|
||||
switch (implId)
|
||||
{
|
||||
case 0x41: name = armPartId2name(partId); break;
|
||||
case 0x42: name = brcmPartId2name(partId); break;
|
||||
case 0x43: name = caviumPartId2name(partId); break;
|
||||
case 0x44: name = decPartId2name(partId); break;
|
||||
case 0x46: name = fujitsuPartId2name(partId); break;
|
||||
case 0x48: name = hisiPartId2name(partId); break;
|
||||
case 0x4e: name = nvidiaPartId2name(partId); break;
|
||||
case 0x50: name = apmPartId2name(partId); break;
|
||||
case 0x51: name = qcomPartId2name(partId); break;
|
||||
case 0x53: name = samsungPartId2name(partId); break;
|
||||
case 0x56: name = marvellPartId2name(partId); break;
|
||||
case 0x61: name = applePartId2name(partId); break;
|
||||
case 0x66: name = faradayPartId2name(partId); break;
|
||||
case 0x69: name = intelPartId2name(partId); break;
|
||||
case 0x6d: name = msPartId2name(partId); break;
|
||||
case 0x70: name = ftPartId2name(partId); break;
|
||||
case 0xc0: name = amperePartId2name(partId); break;
|
||||
}
|
||||
case 0x41: name = armPartId2name(partId); break;
|
||||
case 0x42: name = brcmPartId2name(partId); break;
|
||||
case 0x43: name = caviumPartId2name(partId); break;
|
||||
case 0x44: name = decPartId2name(partId); break;
|
||||
case 0x46: name = fujitsuPartId2name(partId); break;
|
||||
case 0x48: name = hisiPartId2name(partId); break;
|
||||
case 0x4e: name = nvidiaPartId2name(partId); break;
|
||||
case 0x50: name = apmPartId2name(partId); break;
|
||||
case 0x51: name = qcomPartId2name(partId); break;
|
||||
case 0x53: name = samsungPartId2name(partId); break;
|
||||
case 0x56: name = marvellPartId2name(partId); break;
|
||||
case 0x61:
|
||||
if (partId == 0)
|
||||
{
|
||||
// https://github.com/Dr-Noob/cpufetch/issues/213#issuecomment-1927782105
|
||||
ffStrbufSetStatic(&cpu->name, "Virtualized Apple Silicon");
|
||||
return;
|
||||
}
|
||||
name = applePartId2name(partId);
|
||||
break;
|
||||
case 0x66: name = faradayPartId2name(partId); break;
|
||||
case 0x69: name = intelPartId2name(partId); break;
|
||||
case 0x6d: name = msPartId2name(partId); break;
|
||||
case 0x70: name = ftPartId2name(partId); break;
|
||||
case 0xc0: name = amperePartId2name(partId); break;
|
||||
}
|
||||
if (lastPartId != partId)
|
||||
{
|
||||
|
||||
@@ -36,7 +36,9 @@
|
||||
#define FF_WM_PRETTY_ICEWM "IceWM"
|
||||
#define FF_WM_PRETTY_SPECTRWM "spectrwm"
|
||||
#define FF_WM_PRETTY_DTWM "dtwm"
|
||||
|
||||
#define FF_WM_PRETTY_FVWM "fvwm"
|
||||
#define FF_WM_PRETTY_CTWM "ctwm"
|
||||
#define FF_WM_PRETTY_RATPOISON "ratpoison"
|
||||
|
||||
#define FF_WM_PROTOCOL_TTY "TTY"
|
||||
#define FF_WM_PROTOCOL_X11 "X11"
|
||||
|
||||
@@ -126,10 +126,7 @@ static void waylandKdeNameListener(void* data, FF_MAYBE_UNUSED struct kde_output
|
||||
WaylandDisplay* display = data;
|
||||
display->type = ffdsGetDisplayType(name);
|
||||
// As display->id is used as an internal identifier, we don't need it to be NUL terminated
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wstringop-truncation"
|
||||
strncpy((char*) &display->id, name, sizeof(display->id));
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
ffStrbufAppendS(&display->name, name);
|
||||
}
|
||||
|
||||
@@ -18,10 +18,18 @@
|
||||
#include "kde-output-order-v1-client-protocol.h"
|
||||
#include "xdg-output-unstable-v1-client-protocol.h"
|
||||
|
||||
#ifdef __linux__
|
||||
#if __FreeBSD__
|
||||
#include <sys/un.h>
|
||||
#include <sys/ucred.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
static bool waylandDetectWM(int fd, FFDisplayServerResult* result)
|
||||
{
|
||||
struct ucred ucred;
|
||||
#if __linux__ || (__FreeBSD__ && !__DragonFly__)
|
||||
|
||||
#if __linux
|
||||
struct ucred ucred = {};
|
||||
socklen_t len = sizeof(ucred);
|
||||
if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) == -1 || ucred.pid <= 0)
|
||||
return false;
|
||||
@@ -30,6 +38,19 @@ static bool waylandDetectWM(int fd, FFDisplayServerResult* result)
|
||||
ffStrbufAppendF(&procPath, "/proc/%d/cmdline", ucred.pid); //We check the cmdline for the process name, because it is not trimmed.
|
||||
if (!ffReadFileBuffer(procPath.chars, &result->wmProcessName))
|
||||
return false;
|
||||
#else
|
||||
struct xucred ucred = {};
|
||||
socklen_t len = sizeof(ucred);
|
||||
if (getsockopt(fd, AF_UNSPEC, LOCAL_PEERCRED, &ucred, &len) == -1 || ucred.cr_pid <= 0)
|
||||
return false;
|
||||
|
||||
size_t size = 4096;
|
||||
ffStrbufEnsureFixedLengthFree(&result->wmProcessName, (uint32_t) size);
|
||||
|
||||
if(sysctl((int[]){CTL_KERN, KERN_PROC, KERN_PROC_ARGS, ucred.cr_pid}, 4, result->wmProcessName.chars, &size, NULL, 0 ) != 0)
|
||||
return false;
|
||||
result->wmProcessName.length = (uint32_t) size - 1;
|
||||
#endif
|
||||
|
||||
// #1135: wl-restart is a special case
|
||||
const char* filename = strrchr(result->wmProcessName.chars, '/');
|
||||
@@ -45,14 +66,12 @@ static bool waylandDetectWM(int fd, FFDisplayServerResult* result)
|
||||
ffStrbufSubstrAfterLastC(&result->wmProcessName, '/'); //Trim the path
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#else
|
||||
static bool waylandDetectWM(int fd, FFDisplayServerResult* result)
|
||||
{
|
||||
FF_UNUSED(fd, result);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void waylandGlobalAddListener(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
|
||||
{
|
||||
@@ -83,7 +102,7 @@ static void waylandGlobalAddListener(void* data, struct wl_registry* registry, u
|
||||
}
|
||||
}
|
||||
|
||||
static bool matchDrmConnector(const char* connName, WaylandDisplay* wldata)
|
||||
static FF_MAYBE_UNUSED bool matchDrmConnector(const char* connName, WaylandDisplay* wldata)
|
||||
{
|
||||
// https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_output-event-name
|
||||
// The doc says that "do not assume that the name is a reflection of an underlying DRM connector, X11 connection, etc."
|
||||
@@ -129,8 +148,10 @@ void ffWaylandOutputNameListener(void* data, FF_MAYBE_UNUSED void* output, const
|
||||
if (display->id) return;
|
||||
|
||||
display->type = ffdsGetDisplayType(name);
|
||||
#if __linux__
|
||||
if (!display->edidName.length)
|
||||
matchDrmConnector(name, display);
|
||||
#endif
|
||||
display->id = ffWaylandGenerateIdFromName(name);
|
||||
ffStrbufAppendS(&display->name, name);
|
||||
}
|
||||
|
||||
@@ -126,8 +126,14 @@ static void applyPrettyNameIfWM(FFDisplayServerResult* result, const char* name)
|
||||
ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_ICEWM);
|
||||
else if(ffStrEqualsIgnCase(name, "dtwm"))
|
||||
ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_DTWM);
|
||||
else if(ffStrEqualsIgnCase(name, "fvwm"))
|
||||
ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_FVWM);
|
||||
else if(ffStrEqualsIgnCase(name, "ctwm"))
|
||||
ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_CTWM);
|
||||
else if(ffStrEqualsIgnCase(name, "hyprland"))
|
||||
ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_HYPRLAND);
|
||||
else if(ffStrEqualsIgnCase(name, "ratpoison"))
|
||||
ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_RATPOISON);
|
||||
}
|
||||
|
||||
static void applyNameIfWM(FFDisplayServerResult* result, const char* processName)
|
||||
@@ -296,10 +302,10 @@ static const char* getFromProcesses(FFDisplayServerResult* result)
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
if(result->dePrettyName.length == 0)
|
||||
applyPrettyNameIfDE(result, proc->p_comm);
|
||||
applyPrettyNameIfDE(result, proc[i].p_comm);
|
||||
|
||||
if(result->wmPrettyName.length == 0)
|
||||
applyNameIfWM(result, proc->p_comm);
|
||||
applyNameIfWM(result, proc[i].p_comm);
|
||||
|
||||
if(result->dePrettyName.length > 0 && result->wmPrettyName.length > 0)
|
||||
break;
|
||||
|
||||
@@ -188,7 +188,6 @@ static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc, FFstrb
|
||||
{
|
||||
item->hdrStatus = ffEdidGetHdrCompatible(edidData, (uint32_t) edidLength) ? FF_DISPLAY_HDR_STATUS_SUPPORTED : FF_DISPLAY_HDR_STATUS_UNSUPPORTED;
|
||||
ffEdidGetSerialAndManufactureDate(edidData, &item->serial, &item->manufactureYear, &item->manufactureWeek);
|
||||
ffEdidGetPhysicalSize(edidData, &item->physicalWidth, &item->physicalHeight);
|
||||
}
|
||||
|
||||
return !!item;
|
||||
|
||||
@@ -151,7 +151,6 @@ static bool xrandrHandleCrtc(XrandrData* data, XRROutputInfo* output, FFstrbuf*
|
||||
{
|
||||
item->hdrStatus = ffEdidGetHdrCompatible(edidData, edidLength) ? FF_DISPLAY_HDR_STATUS_SUPPORTED : FF_DISPLAY_HDR_STATUS_UNSUPPORTED;
|
||||
ffEdidGetSerialAndManufactureDate(edidData, &item->serial, &item->manufactureYear, &item->manufactureWeek);
|
||||
ffEdidGetPhysicalSize(edidData, &item->physicalWidth, &item->physicalHeight);
|
||||
}
|
||||
|
||||
data->ffXRRFreeCrtcInfo(crtcInfo);
|
||||
|
||||
@@ -3,10 +3,14 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#ifdef __FreeBSD__
|
||||
#include <paths.h>
|
||||
#include <paths.h>
|
||||
#ifndef _PATH_LOCALBASE
|
||||
#define _PATH_LOCALBASE "/usr/local"
|
||||
#endif
|
||||
#elif __OpenBSD__
|
||||
#define _PATH_LOCALBASE "/usr/local"
|
||||
#elif __NetBSD__
|
||||
#define _PATH_LOCALBASE "/usr/pkg"
|
||||
#endif
|
||||
|
||||
#if FF_HAVE_EMBEDDED_PCIIDS
|
||||
@@ -37,17 +41,10 @@ static const FFstrbuf* loadPciIds()
|
||||
if (pciids.length == 0)
|
||||
ffReadFileBuffer(FASTFETCH_TARGET_DIR_USR "/local/share/hwdata/pci.ids", &pciids);
|
||||
}
|
||||
#elif __FreeBSD__
|
||||
// https://github.com/freebsd/freebsd-src/blob/main/usr.sbin/pciconf/pathnames.h
|
||||
#elif __FreeBSD__ || __OpenBSD__ || __NetBSD__
|
||||
ffReadFileBuffer(_PATH_LOCALBASE "/share/pciids/pci.ids", &pciids);
|
||||
if (pciids.length == 0)
|
||||
ffReadFileBuffer(FASTFETCH_TARGET_DIR_USR "/share/pciids/pci.ids", &pciids);
|
||||
#elif __sun
|
||||
ffReadFileBuffer(FASTFETCH_TARGET_DIR_ROOT "/usr/share/hwdata/pci.ids", &pciids);
|
||||
#elif __OpenBSD__
|
||||
ffReadFileBuffer(FASTFETCH_TARGET_DIR_ROOT "/usr/local/share/pci.ids", &pciids);
|
||||
#elif __NetBSD__
|
||||
ffReadFileBuffer(FASTFETCH_TARGET_DIR_ROOT "/usr/pkg/share/pciutils/pci.ids", &pciids);
|
||||
#endif
|
||||
|
||||
#endif // FF_CUSTOM_PCI_IDS_PATH
|
||||
|
||||
@@ -13,4 +13,8 @@ typedef struct FFHostResult
|
||||
FFstrbuf vendor;
|
||||
} FFHostResult;
|
||||
|
||||
const char* ffHostGetMacProductNameWithHwModel(const FFstrbuf* hwModel);
|
||||
#ifdef __x86_64__
|
||||
bool ffHostDetectMac(FFHostResult* host);
|
||||
#endif
|
||||
const char* ffDetectHost(FFHostResult* host);
|
||||
|
||||
@@ -5,179 +5,6 @@
|
||||
|
||||
#include <IOKit/IOKitLib.h>
|
||||
|
||||
static const char* getProductNameWithHwModel(const FFstrbuf* hwModel)
|
||||
{
|
||||
// Macbook Pro: https://support.apple.com/en-us/HT201300
|
||||
// Macbook Air: https://support.apple.com/en-us/HT201862
|
||||
// Mac mini: https://support.apple.com/en-us/HT201894
|
||||
// iMac: https://support.apple.com/en-us/HT201634
|
||||
// Mac Pro: https://support.apple.com/en-us/HT202888
|
||||
// Mac Studio: https://support.apple.com/en-us/HT213073
|
||||
|
||||
if(ffStrbufStartsWithS(hwModel, "MacBookPro"))
|
||||
{
|
||||
const char* version = hwModel->chars + strlen("MacBookPro");
|
||||
if(ffStrEquals(version, "18,3") ||
|
||||
ffStrEquals(version, "18,4")) return "MacBook Pro (14-inch, 2021)";
|
||||
if(ffStrEquals(version, "18,1") ||
|
||||
ffStrEquals(version, "18,2")) return "MacBook Pro (16-inch, 2021)";
|
||||
if(ffStrEquals(version, "17,1")) return "MacBook Pro (13-inch, M1, 2020)";
|
||||
if(ffStrEquals(version, "16,3")) return "MacBook Pro (13-inch, 2020, Two Thunderbolt 3 ports)";
|
||||
if(ffStrEquals(version, "16,2")) return "MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports)";
|
||||
if(ffStrEquals(version, "16,4") ||
|
||||
ffStrEquals(version, "16,1")) return "MacBook Pro (16-inch, 2019)";
|
||||
if(ffStrEquals(version, "15,4")) return "MacBook Pro (13-inch, 2019, Two Thunderbolt 3 ports)";
|
||||
if(ffStrEquals(version, "15,3")) return "MacBook Pro (15-inch, 2019)";
|
||||
if(ffStrEquals(version, "15,2")) return "MacBook Pro (13-inch, 2018/2019, Four Thunderbolt 3 ports)";
|
||||
if(ffStrEquals(version, "15,1")) return "MacBook Pro (15-inch, 2018/2019)";
|
||||
if(ffStrEquals(version, "14,3")) return "MacBook Pro (15-inch, 2017)";
|
||||
if(ffStrEquals(version, "14,2")) return "MacBook Pro (13-inch, 2017, Four Thunderbolt 3 ports)";
|
||||
if(ffStrEquals(version, "14,1")) return "MacBook Pro (13-inch, 2017, Two Thunderbolt 3 ports)";
|
||||
if(ffStrEquals(version, "13,3")) return "MacBook Pro (15-inch, 2016)";
|
||||
if(ffStrEquals(version, "13,2")) return "MacBook Pro (13-inch, 2016, Four Thunderbolt 3 ports)";
|
||||
if(ffStrEquals(version, "13,1")) return "MacBook Pro (13-inch, 2016, Two Thunderbolt 3 ports)";
|
||||
if(ffStrEquals(version, "12,1")) return "MacBook Pro (Retina, 13-inch, Early 2015)";
|
||||
if(ffStrEquals(version, "11,4") ||
|
||||
ffStrEquals(version, "11,5")) return "MacBook Pro (Retina, 15-inch, Mid 2015)";
|
||||
if(ffStrEquals(version, "11,2") ||
|
||||
ffStrEquals(version, "11,3")) return "MacBook Pro (Retina, 15-inch, Late 2013/Mid 2014)";
|
||||
if(ffStrEquals(version, "11,1")) return "MacBook Pro (Retina, 13-inch, Late 2013/Mid 2014)";
|
||||
if(ffStrEquals(version, "10,2")) return "MacBook Pro (Retina, 13-inch, Late 2012/Early 2013)";
|
||||
if(ffStrEquals(version, "10,1")) return "MacBook Pro (Retina, 15-inch, Mid 2012/Early 2013)";
|
||||
if(ffStrEquals(version, "9,2")) return "MacBook Pro (13-inch, Mid 2012)";
|
||||
if(ffStrEquals(version, "9,1")) return "MacBook Pro (15-inch, Mid 2012)";
|
||||
if(ffStrEquals(version, "8,3")) return "MacBook Pro (17-inch, 2011)";
|
||||
if(ffStrEquals(version, "8,2")) return "MacBook Pro (15-inch, 2011)";
|
||||
if(ffStrEquals(version, "8,1")) return "MacBook Pro (13-inch, 2011)";
|
||||
if(ffStrEquals(version, "7,1")) return "MacBook Pro (13-inch, Mid 2010)";
|
||||
if(ffStrEquals(version, "6,2")) return "MacBook Pro (15-inch, Mid 2010)";
|
||||
if(ffStrEquals(version, "6,1")) return "MacBook Pro (17-inch, Mid 2010)";
|
||||
if(ffStrEquals(version, "5,5")) return "MacBook Pro (13-inch, Mid 2009)";
|
||||
if(ffStrEquals(version, "5,3")) return "MacBook Pro (15-inch, Mid 2009)";
|
||||
if(ffStrEquals(version, "5,2")) return "MacBook Pro (17-inch, Mid/Early 2009)";
|
||||
if(ffStrEquals(version, "5,1")) return "MacBook Pro (15-inch, Late 2008)";
|
||||
if(ffStrEquals(version, "4,1")) return "MacBook Pro (17/15-inch, Early 2008)";
|
||||
}
|
||||
else if(ffStrbufStartsWithS(hwModel, "MacBookAir"))
|
||||
{
|
||||
const char* version = hwModel->chars + strlen("MacBookAir");
|
||||
if(ffStrEquals(version, "10,1")) return "MacBook Air (M1, 2020)";
|
||||
if(ffStrEquals(version, "9,1")) return "MacBook Air (Retina, 13-inch, 2020)";
|
||||
if(ffStrEquals(version, "8,2")) return "MacBook Air (Retina, 13-inch, 2019)";
|
||||
if(ffStrEquals(version, "8,1")) return "MacBook Air (Retina, 13-inch, 2018)";
|
||||
if(ffStrEquals(version, "7,2")) return "MacBook Air (13-inch, Early 2015/2017)";
|
||||
if(ffStrEquals(version, "7,1")) return "MacBook Air (11-inch, Early 2015)";
|
||||
if(ffStrEquals(version, "6,2")) return "MacBook Air (13-inch, Mid 2013/Early 2014)";
|
||||
if(ffStrEquals(version, "6,1")) return "MacBook Air (11-inch, Mid 2013/Early 2014)";
|
||||
if(ffStrEquals(version, "5,2")) return "MacBook Air (13-inch, Mid 2012)";
|
||||
if(ffStrEquals(version, "5,1")) return "MacBook Air (11-inch, Mid 2012)";
|
||||
if(ffStrEquals(version, "4,2")) return "MacBook Air (13-inch, Mid 2011)";
|
||||
if(ffStrEquals(version, "4,1")) return "MacBook Air (11-inch, Mid 2011)";
|
||||
if(ffStrEquals(version, "3,2")) return "MacBook Air (13-inch, Late 2010)";
|
||||
if(ffStrEquals(version, "3,1")) return "MacBook Air (11-inch, Late 2010)";
|
||||
if(ffStrEquals(version, "2,1")) return "MacBook Air (Mid 2009)";
|
||||
}
|
||||
else if(ffStrbufStartsWithS(hwModel, "Macmini"))
|
||||
{
|
||||
const char* version = hwModel->chars + strlen("Macmini");
|
||||
if(ffStrEquals(version, "9,1")) return "Mac mini (M1, 2020)";
|
||||
if(ffStrEquals(version, "8,1")) return "Mac mini (2018)";
|
||||
if(ffStrEquals(version, "7,1")) return "Mac mini (Mid 2014)";
|
||||
if(ffStrEquals(version, "6,1") ||
|
||||
ffStrEquals(version, "6,2")) return "Mac mini (Late 2012)";
|
||||
if(ffStrEquals(version, "5,1") ||
|
||||
ffStrEquals(version, "5,2")) return "Mac mini (Mid 2011)";
|
||||
if(ffStrEquals(version, "4,1")) return "Mac mini (Mid 2010)";
|
||||
if(ffStrEquals(version, "3,1")) return "Mac mini (Early/Late 2009)";
|
||||
}
|
||||
else if(ffStrbufStartsWithS(hwModel, "MacBook"))
|
||||
{
|
||||
const char* version = hwModel->chars + strlen("MacBook");
|
||||
if(ffStrEquals(version, "10,1")) return "MacBook (Retina, 12-inch, 2017)";
|
||||
if(ffStrEquals(version, "9,1")) return "MacBook (Retina, 12-inch, Early 2016)";
|
||||
if(ffStrEquals(version, "8,1")) return "MacBook (Retina, 12-inch, Early 2015)";
|
||||
if(ffStrEquals(version, "7,1")) return "MacBook (13-inch, Mid 2010)";
|
||||
if(ffStrEquals(version, "6,1")) return "MacBook (13-inch, Late 2009)";
|
||||
if(ffStrEquals(version, "5,2")) return "MacBook (13-inch, Early/Mid 2009)";
|
||||
}
|
||||
else if(ffStrbufStartsWithS(hwModel, "MacPro"))
|
||||
{
|
||||
const char* version = hwModel->chars + strlen("MacPro");
|
||||
if(ffStrEquals(version, "7,1")) return "Mac Pro (2019)";
|
||||
if(ffStrEquals(version, "6,1")) return "Mac Pro (Late 2013)";
|
||||
if(ffStrEquals(version, "5,1")) return "Mac Pro (Mid 2010 - Mid 2012)";
|
||||
if(ffStrEquals(version, "4,1")) return "Mac Pro (Early 2009)";
|
||||
}
|
||||
else if(ffStrbufStartsWithS(hwModel, "Mac"))
|
||||
{
|
||||
const char* version = hwModel->chars + strlen("Mac");
|
||||
if(ffStrEquals(version, "16,3")) return "iMac (24-inch, 2024, Four Thunderbolt / USB 4 ports)";
|
||||
if(ffStrEquals(version, "16,2")) return "iMac (24-inch, 2024, Two Thunderbolt / USB 4 ports)";
|
||||
if(ffStrEquals(version, "16,1") ||
|
||||
ffStrEquals(version, "16,6") ||
|
||||
ffStrEquals(version, "16,8")) return "MacBook Pro (14-inch, 2024, Three Thunderbolt 4 ports)";
|
||||
if(ffStrEquals(version, "16,7") ||
|
||||
ffStrEquals(version, "16,5")) return "MacBook Pro (16-inch, 2024, Three Thunderbolt 4 ports)";
|
||||
if(ffStrEquals(version, "16,15") ||
|
||||
ffStrEquals(version, "16,10")) return "Mac mini (2024)";
|
||||
if(ffStrEquals(version, "15,13")) return "MacBook Air (15-inch, M3, 2024)";
|
||||
if(ffStrEquals(version, "15,2")) return "MacBook Air (13-inch, M3, 2024)";
|
||||
if(ffStrEquals(version, "15,3")) return "MacBook Pro (14-inch, Nov 2023, Two Thunderbolt / USB 4 ports)";
|
||||
if(ffStrEquals(version, "15,4")) return "iMac (24-inch, 2023, Two Thunderbolt / USB 4 ports)";
|
||||
if(ffStrEquals(version, "15,5")) return "iMac (24-inch, 2023, Two Thunderbolt / USB 4 ports, Two USB 3 ports)";
|
||||
if(ffStrEquals(version, "15,6") ||
|
||||
ffStrEquals(version, "15,8") ||
|
||||
ffStrEquals(version, "15,10")) return "MacBook Pro (14-inch, Nov 2023, Three Thunderbolt 4 ports)";
|
||||
if(ffStrEquals(version, "15,7") ||
|
||||
ffStrEquals(version, "15,9") ||
|
||||
ffStrEquals(version, "15,11")) return "MacBook Pro (16-inch, Nov 2023, Three Thunderbolt 4 ports)";
|
||||
if(ffStrEquals(version, "14,15")) return "MacBook Air (15-inch, M2, 2023)";
|
||||
if(ffStrEquals(version, "14,14")) return "Mac Studio (M2 Ultra, 2023, Two Thunderbolt 4 front ports)";
|
||||
if(ffStrEquals(version, "14,13")) return "Mac Studio (M2 Max, 2023, Two USB-C front ports)";
|
||||
if(ffStrEquals(version, "14,8")) return "Mac Pro (2023)";
|
||||
if(ffStrEquals(version, "14,6") ||
|
||||
ffStrEquals(version, "14,10")) return "MacBook Pro (16-inch, 2023)";
|
||||
if(ffStrEquals(version, "14,5") ||
|
||||
ffStrEquals(version, "14,9")) return "MacBook Pro (14-inch, 2023)";
|
||||
if(ffStrEquals(version, "14,3")) return "Mac mini (M2, 2023, Two Thunderbolt 4 ports)";
|
||||
if(ffStrEquals(version, "14,12")) return "Mac mini (M2, 2023, Four Thunderbolt 4 ports)";
|
||||
if(ffStrEquals(version, "14,7")) return "MacBook Pro (13-inch, M2, 2022)";
|
||||
if(ffStrEquals(version, "14,2")) return "MacBook Air (M2, 2022)";
|
||||
if(ffStrEquals(version, "13,1")) return "Mac Studio (M1 Max, 2022, Two USB-C front ports)";
|
||||
if(ffStrEquals(version, "13,2")) return "Mac Studio (M1 Ultra, 2022, Two Thunderbolt 4 front ports)";
|
||||
}
|
||||
else if(ffStrbufStartsWithS(hwModel, "iMac"))
|
||||
{
|
||||
const char* version = hwModel->chars + strlen("iMac");
|
||||
if(ffStrEquals(version, "21,1")) return "iMac (24-inch, M1, 2021, Two Thunderbolt / USB 4 ports, Two USB 3 ports)";
|
||||
if(ffStrEquals(version, "21,2")) return "iMac (24-inch, M1, 2021, Two Thunderbolt / USB 4 ports)";
|
||||
if(ffStrEquals(version, "20,1") ||
|
||||
ffStrEquals(version, "20,2")) return "iMac (Retina 5K, 27-inch, 2020)";
|
||||
if(ffStrEquals(version, "19,1")) return "iMac (Retina 5K, 27-inch, 2019)";
|
||||
if(ffStrEquals(version, "19,2")) return "iMac (Retina 4K, 21.5-inch, 2019)";
|
||||
if(ffStrEquals(version, "Pro1,1")) return "iMac Pro (2017)";
|
||||
if(ffStrEquals(version, "18,3")) return "iMac (Retina 5K, 27-inch, 2017)";
|
||||
if(ffStrEquals(version, "18,2")) return "iMac (Retina 4K, 21.5-inch, 2017)";
|
||||
if(ffStrEquals(version, "18,1")) return "iMac (21.5-inch, 2017)";
|
||||
if(ffStrEquals(version, "17,1")) return "iMac (Retina 5K, 27-inch, Late 2015)";
|
||||
if(ffStrEquals(version, "16,2")) return "iMac (Retina 4K, 21.5-inch, Late 2015)";
|
||||
if(ffStrEquals(version, "16,1")) return "iMac (21.5-inch, Late 2015)";
|
||||
if(ffStrEquals(version, "15,1")) return "iMac (Retina 5K, 27-inch, Late 2014 - Mid 2015)";
|
||||
if(ffStrEquals(version, "14,4")) return "iMac (21.5-inch, Mid 2014)";
|
||||
if(ffStrEquals(version, "14,2")) return "iMac (27-inch, Late 2013)";
|
||||
if(ffStrEquals(version, "14,1")) return "iMac (21.5-inch, Late 2013)";
|
||||
if(ffStrEquals(version, "13,2")) return "iMac (27-inch, Late 2012)";
|
||||
if(ffStrEquals(version, "13,1")) return "iMac (21.5-inch, Late 2012)";
|
||||
if(ffStrEquals(version, "12,2")) return "iMac (27-inch, Mid 2011)";
|
||||
if(ffStrEquals(version, "12,1")) return "iMac (21.5-inch, Mid 2011)";
|
||||
if(ffStrEquals(version, "11,3")) return "iMac (27-inch, Mid 2010)";
|
||||
if(ffStrEquals(version, "11,2")) return "iMac (21.5-inch, Mid 2010)";
|
||||
if(ffStrEquals(version, "10,1")) return "iMac (27/21.5-inch, Late 2009)";
|
||||
if(ffStrEquals(version, "9,1")) return "iMac (24/20-inch, Early 2009)";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* getProductNameWithIokit(FFstrbuf* result)
|
||||
{
|
||||
FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t registryEntry = IOServiceGetMatchingService(MACH_PORT_NULL, IOServiceNameMatching("product"));
|
||||
@@ -217,7 +44,7 @@ const char* ffDetectHost(FFHostResult* host)
|
||||
const char* error = ffSysctlGetString("hw.model", &host->family);
|
||||
if (error) return error;
|
||||
|
||||
ffStrbufSetStatic(&host->name, getProductNameWithHwModel(&host->family));
|
||||
ffStrbufSetStatic(&host->name, ffHostGetMacProductNameWithHwModel(&host->family));
|
||||
if (host->name.length == 0)
|
||||
getProductNameWithIokit(&host->name);
|
||||
if (host->name.length == 0)
|
||||
|
||||
@@ -19,5 +19,9 @@ const char* ffDetectHost(FFHostResult* host)
|
||||
ffSettingsGetFreeBSDKenv("smbios.system.maker", &host->vendor);
|
||||
ffCleanUpSmbiosValue(&host->vendor);
|
||||
|
||||
#ifdef __x86_64__
|
||||
ffHostDetectMac(host);
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -63,6 +63,10 @@ const char* ffDetectHost(FFHostResult* host)
|
||||
ffStrbufSetStatic(&host->vendor, "Apple Inc.");
|
||||
}
|
||||
|
||||
#ifdef __x86_64__
|
||||
ffHostDetectMac(host);
|
||||
#endif
|
||||
|
||||
//KVM/Qemu virtual machine
|
||||
if(ffStrbufStartsWithS(&host->name, "Standard PC"))
|
||||
ffStrbufPrependS(&host->name, "KVM/QEMU ");
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
#include "host.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
const char* ffHostGetMacProductNameWithHwModel(const FFstrbuf* hwModel)
|
||||
{
|
||||
// Macbook Pro: https://support.apple.com/en-us/HT201300
|
||||
// Macbook Air: https://support.apple.com/en-us/HT201862
|
||||
// Mac mini: https://support.apple.com/en-us/HT201894
|
||||
// iMac: https://support.apple.com/en-us/HT201634
|
||||
// Mac Pro: https://support.apple.com/en-us/HT202888
|
||||
// Mac Studio: https://support.apple.com/en-us/HT213073
|
||||
|
||||
if(ffStrbufStartsWithS(hwModel, "MacBookPro"))
|
||||
{
|
||||
const char* version = hwModel->chars + strlen("MacBookPro");
|
||||
if(ffStrEquals(version, "18,3") ||
|
||||
ffStrEquals(version, "18,4")) return "MacBook Pro (14-inch, 2021)";
|
||||
if(ffStrEquals(version, "18,1") ||
|
||||
ffStrEquals(version, "18,2")) return "MacBook Pro (16-inch, 2021)";
|
||||
if(ffStrEquals(version, "17,1")) return "MacBook Pro (13-inch, M1, 2020)";
|
||||
if(ffStrEquals(version, "16,3")) return "MacBook Pro (13-inch, 2020, Two Thunderbolt 3 ports)";
|
||||
if(ffStrEquals(version, "16,2")) return "MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports)";
|
||||
if(ffStrEquals(version, "16,4") ||
|
||||
ffStrEquals(version, "16,1")) return "MacBook Pro (16-inch, 2019)";
|
||||
if(ffStrEquals(version, "15,4")) return "MacBook Pro (13-inch, 2019, Two Thunderbolt 3 ports)";
|
||||
if(ffStrEquals(version, "15,3")) return "MacBook Pro (15-inch, 2019)";
|
||||
if(ffStrEquals(version, "15,2")) return "MacBook Pro (13-inch, 2018/2019, Four Thunderbolt 3 ports)";
|
||||
if(ffStrEquals(version, "15,1")) return "MacBook Pro (15-inch, 2018/2019)";
|
||||
if(ffStrEquals(version, "14,3")) return "MacBook Pro (15-inch, 2017)";
|
||||
if(ffStrEquals(version, "14,2")) return "MacBook Pro (13-inch, 2017, Four Thunderbolt 3 ports)";
|
||||
if(ffStrEquals(version, "14,1")) return "MacBook Pro (13-inch, 2017, Two Thunderbolt 3 ports)";
|
||||
if(ffStrEquals(version, "13,3")) return "MacBook Pro (15-inch, 2016)";
|
||||
if(ffStrEquals(version, "13,2")) return "MacBook Pro (13-inch, 2016, Four Thunderbolt 3 ports)";
|
||||
if(ffStrEquals(version, "13,1")) return "MacBook Pro (13-inch, 2016, Two Thunderbolt 3 ports)";
|
||||
if(ffStrEquals(version, "12,1")) return "MacBook Pro (Retina, 13-inch, Early 2015)";
|
||||
if(ffStrEquals(version, "11,4") ||
|
||||
ffStrEquals(version, "11,5")) return "MacBook Pro (Retina, 15-inch, Mid 2015)";
|
||||
if(ffStrEquals(version, "11,2") ||
|
||||
ffStrEquals(version, "11,3")) return "MacBook Pro (Retina, 15-inch, Late 2013/Mid 2014)";
|
||||
if(ffStrEquals(version, "11,1")) return "MacBook Pro (Retina, 13-inch, Late 2013/Mid 2014)";
|
||||
if(ffStrEquals(version, "10,2")) return "MacBook Pro (Retina, 13-inch, Late 2012/Early 2013)";
|
||||
if(ffStrEquals(version, "10,1")) return "MacBook Pro (Retina, 15-inch, Mid 2012/Early 2013)";
|
||||
if(ffStrEquals(version, "9,2")) return "MacBook Pro (13-inch, Mid 2012)";
|
||||
if(ffStrEquals(version, "9,1")) return "MacBook Pro (15-inch, Mid 2012)";
|
||||
if(ffStrEquals(version, "8,3")) return "MacBook Pro (17-inch, 2011)";
|
||||
if(ffStrEquals(version, "8,2")) return "MacBook Pro (15-inch, 2011)";
|
||||
if(ffStrEquals(version, "8,1")) return "MacBook Pro (13-inch, 2011)";
|
||||
if(ffStrEquals(version, "7,1")) return "MacBook Pro (13-inch, Mid 2010)";
|
||||
if(ffStrEquals(version, "6,2")) return "MacBook Pro (15-inch, Mid 2010)";
|
||||
if(ffStrEquals(version, "6,1")) return "MacBook Pro (17-inch, Mid 2010)";
|
||||
if(ffStrEquals(version, "5,5")) return "MacBook Pro (13-inch, Mid 2009)";
|
||||
if(ffStrEquals(version, "5,3")) return "MacBook Pro (15-inch, Mid 2009)";
|
||||
if(ffStrEquals(version, "5,2")) return "MacBook Pro (17-inch, Mid/Early 2009)";
|
||||
if(ffStrEquals(version, "5,1")) return "MacBook Pro (15-inch, Late 2008)";
|
||||
if(ffStrEquals(version, "4,1")) return "MacBook Pro (17/15-inch, Early 2008)";
|
||||
}
|
||||
else if(ffStrbufStartsWithS(hwModel, "MacBookAir"))
|
||||
{
|
||||
const char* version = hwModel->chars + strlen("MacBookAir");
|
||||
if(ffStrEquals(version, "10,1")) return "MacBook Air (M1, 2020)";
|
||||
if(ffStrEquals(version, "9,1")) return "MacBook Air (Retina, 13-inch, 2020)";
|
||||
if(ffStrEquals(version, "8,2")) return "MacBook Air (Retina, 13-inch, 2019)";
|
||||
if(ffStrEquals(version, "8,1")) return "MacBook Air (Retina, 13-inch, 2018)";
|
||||
if(ffStrEquals(version, "7,2")) return "MacBook Air (13-inch, Early 2015/2017)";
|
||||
if(ffStrEquals(version, "7,1")) return "MacBook Air (11-inch, Early 2015)";
|
||||
if(ffStrEquals(version, "6,2")) return "MacBook Air (13-inch, Mid 2013/Early 2014)";
|
||||
if(ffStrEquals(version, "6,1")) return "MacBook Air (11-inch, Mid 2013/Early 2014)";
|
||||
if(ffStrEquals(version, "5,2")) return "MacBook Air (13-inch, Mid 2012)";
|
||||
if(ffStrEquals(version, "5,1")) return "MacBook Air (11-inch, Mid 2012)";
|
||||
if(ffStrEquals(version, "4,2")) return "MacBook Air (13-inch, Mid 2011)";
|
||||
if(ffStrEquals(version, "4,1")) return "MacBook Air (11-inch, Mid 2011)";
|
||||
if(ffStrEquals(version, "3,2")) return "MacBook Air (13-inch, Late 2010)";
|
||||
if(ffStrEquals(version, "3,1")) return "MacBook Air (11-inch, Late 2010)";
|
||||
if(ffStrEquals(version, "2,1")) return "MacBook Air (Mid 2009)";
|
||||
}
|
||||
else if(ffStrbufStartsWithS(hwModel, "Macmini"))
|
||||
{
|
||||
const char* version = hwModel->chars + strlen("Macmini");
|
||||
if(ffStrEquals(version, "9,1")) return "Mac mini (M1, 2020)";
|
||||
if(ffStrEquals(version, "8,1")) return "Mac mini (2018)";
|
||||
if(ffStrEquals(version, "7,1")) return "Mac mini (Mid 2014)";
|
||||
if(ffStrEquals(version, "6,1") ||
|
||||
ffStrEquals(version, "6,2")) return "Mac mini (Late 2012)";
|
||||
if(ffStrEquals(version, "5,1") ||
|
||||
ffStrEquals(version, "5,2")) return "Mac mini (Mid 2011)";
|
||||
if(ffStrEquals(version, "4,1")) return "Mac mini (Mid 2010)";
|
||||
if(ffStrEquals(version, "3,1")) return "Mac mini (Early/Late 2009)";
|
||||
}
|
||||
else if(ffStrbufStartsWithS(hwModel, "MacBook"))
|
||||
{
|
||||
const char* version = hwModel->chars + strlen("MacBook");
|
||||
if(ffStrEquals(version, "10,1")) return "MacBook (Retina, 12-inch, 2017)";
|
||||
if(ffStrEquals(version, "9,1")) return "MacBook (Retina, 12-inch, Early 2016)";
|
||||
if(ffStrEquals(version, "8,1")) return "MacBook (Retina, 12-inch, Early 2015)";
|
||||
if(ffStrEquals(version, "7,1")) return "MacBook (13-inch, Mid 2010)";
|
||||
if(ffStrEquals(version, "6,1")) return "MacBook (13-inch, Late 2009)";
|
||||
if(ffStrEquals(version, "5,2")) return "MacBook (13-inch, Early/Mid 2009)";
|
||||
}
|
||||
else if(ffStrbufStartsWithS(hwModel, "MacPro"))
|
||||
{
|
||||
const char* version = hwModel->chars + strlen("MacPro");
|
||||
if(ffStrEquals(version, "7,1")) return "Mac Pro (2019)";
|
||||
if(ffStrEquals(version, "6,1")) return "Mac Pro (Late 2013)";
|
||||
if(ffStrEquals(version, "5,1")) return "Mac Pro (Mid 2010 - Mid 2012)";
|
||||
if(ffStrEquals(version, "4,1")) return "Mac Pro (Early 2009)";
|
||||
}
|
||||
else if(ffStrbufStartsWithS(hwModel, "Mac"))
|
||||
{
|
||||
const char* version = hwModel->chars + strlen("Mac");
|
||||
if(ffStrEquals(version, "16,3")) return "iMac (24-inch, 2024, Four Thunderbolt / USB 4 ports)";
|
||||
if(ffStrEquals(version, "16,2")) return "iMac (24-inch, 2024, Two Thunderbolt / USB 4 ports)";
|
||||
if(ffStrEquals(version, "16,1") ||
|
||||
ffStrEquals(version, "16,6") ||
|
||||
ffStrEquals(version, "16,8")) return "MacBook Pro (14-inch, 2024, Three Thunderbolt 4 ports)";
|
||||
if(ffStrEquals(version, "16,7") ||
|
||||
ffStrEquals(version, "16,5")) return "MacBook Pro (16-inch, 2024, Three Thunderbolt 4 ports)";
|
||||
if(ffStrEquals(version, "16,15") ||
|
||||
ffStrEquals(version, "16,10")) return "Mac mini (2024)";
|
||||
if(ffStrEquals(version, "15,13")) return "MacBook Air (15-inch, M3, 2024)";
|
||||
if(ffStrEquals(version, "15,2")) return "MacBook Air (13-inch, M3, 2024)";
|
||||
if(ffStrEquals(version, "15,3")) return "MacBook Pro (14-inch, Nov 2023, Two Thunderbolt / USB 4 ports)";
|
||||
if(ffStrEquals(version, "15,4")) return "iMac (24-inch, 2023, Two Thunderbolt / USB 4 ports)";
|
||||
if(ffStrEquals(version, "15,5")) return "iMac (24-inch, 2023, Two Thunderbolt / USB 4 ports, Two USB 3 ports)";
|
||||
if(ffStrEquals(version, "15,6") ||
|
||||
ffStrEquals(version, "15,8") ||
|
||||
ffStrEquals(version, "15,10")) return "MacBook Pro (14-inch, Nov 2023, Three Thunderbolt 4 ports)";
|
||||
if(ffStrEquals(version, "15,7") ||
|
||||
ffStrEquals(version, "15,9") ||
|
||||
ffStrEquals(version, "15,11")) return "MacBook Pro (16-inch, Nov 2023, Three Thunderbolt 4 ports)";
|
||||
if(ffStrEquals(version, "14,15")) return "MacBook Air (15-inch, M2, 2023)";
|
||||
if(ffStrEquals(version, "14,14")) return "Mac Studio (M2 Ultra, 2023, Two Thunderbolt 4 front ports)";
|
||||
if(ffStrEquals(version, "14,13")) return "Mac Studio (M2 Max, 2023, Two USB-C front ports)";
|
||||
if(ffStrEquals(version, "14,8")) return "Mac Pro (2023)";
|
||||
if(ffStrEquals(version, "14,6") ||
|
||||
ffStrEquals(version, "14,10")) return "MacBook Pro (16-inch, 2023)";
|
||||
if(ffStrEquals(version, "14,5") ||
|
||||
ffStrEquals(version, "14,9")) return "MacBook Pro (14-inch, 2023)";
|
||||
if(ffStrEquals(version, "14,3")) return "Mac mini (M2, 2023, Two Thunderbolt 4 ports)";
|
||||
if(ffStrEquals(version, "14,12")) return "Mac mini (M2, 2023, Four Thunderbolt 4 ports)";
|
||||
if(ffStrEquals(version, "14,7")) return "MacBook Pro (13-inch, M2, 2022)";
|
||||
if(ffStrEquals(version, "14,2")) return "MacBook Air (M2, 2022)";
|
||||
if(ffStrEquals(version, "13,1")) return "Mac Studio (M1 Max, 2022, Two USB-C front ports)";
|
||||
if(ffStrEquals(version, "13,2")) return "Mac Studio (M1 Ultra, 2022, Two Thunderbolt 4 front ports)";
|
||||
}
|
||||
else if(ffStrbufStartsWithS(hwModel, "iMac"))
|
||||
{
|
||||
const char* version = hwModel->chars + strlen("iMac");
|
||||
if(ffStrEquals(version, "21,1")) return "iMac (24-inch, M1, 2021, Two Thunderbolt / USB 4 ports, Two USB 3 ports)";
|
||||
if(ffStrEquals(version, "21,2")) return "iMac (24-inch, M1, 2021, Two Thunderbolt / USB 4 ports)";
|
||||
if(ffStrEquals(version, "20,1") ||
|
||||
ffStrEquals(version, "20,2")) return "iMac (Retina 5K, 27-inch, 2020)";
|
||||
if(ffStrEquals(version, "19,1")) return "iMac (Retina 5K, 27-inch, 2019)";
|
||||
if(ffStrEquals(version, "19,2")) return "iMac (Retina 4K, 21.5-inch, 2019)";
|
||||
if(ffStrEquals(version, "Pro1,1")) return "iMac Pro (2017)";
|
||||
if(ffStrEquals(version, "18,3")) return "iMac (Retina 5K, 27-inch, 2017)";
|
||||
if(ffStrEquals(version, "18,2")) return "iMac (Retina 4K, 21.5-inch, 2017)";
|
||||
if(ffStrEquals(version, "18,1")) return "iMac (21.5-inch, 2017)";
|
||||
if(ffStrEquals(version, "17,1")) return "iMac (Retina 5K, 27-inch, Late 2015)";
|
||||
if(ffStrEquals(version, "16,2")) return "iMac (Retina 4K, 21.5-inch, Late 2015)";
|
||||
if(ffStrEquals(version, "16,1")) return "iMac (21.5-inch, Late 2015)";
|
||||
if(ffStrEquals(version, "15,1")) return "iMac (Retina 5K, 27-inch, Late 2014 - Mid 2015)";
|
||||
if(ffStrEquals(version, "14,4")) return "iMac (21.5-inch, Mid 2014)";
|
||||
if(ffStrEquals(version, "14,2")) return "iMac (27-inch, Late 2013)";
|
||||
if(ffStrEquals(version, "14,1")) return "iMac (21.5-inch, Late 2013)";
|
||||
if(ffStrEquals(version, "13,2")) return "iMac (27-inch, Late 2012)";
|
||||
if(ffStrEquals(version, "13,1")) return "iMac (21.5-inch, Late 2012)";
|
||||
if(ffStrEquals(version, "12,2")) return "iMac (27-inch, Mid 2011)";
|
||||
if(ffStrEquals(version, "12,1")) return "iMac (21.5-inch, Mid 2011)";
|
||||
if(ffStrEquals(version, "11,3")) return "iMac (27-inch, Mid 2010)";
|
||||
if(ffStrEquals(version, "11,2")) return "iMac (21.5-inch, Mid 2010)";
|
||||
if(ffStrEquals(version, "10,1")) return "iMac (27/21.5-inch, Late 2009)";
|
||||
if(ffStrEquals(version, "9,1")) return "iMac (24/20-inch, Early 2009)";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef __x86_64__
|
||||
bool ffHostDetectMac(FFHostResult* host)
|
||||
{
|
||||
if (ffStrbufEqualS(&host->family, "Mac") && ffStrbufEqualS(&host->vendor, "Apple Inc."))
|
||||
{
|
||||
const char* productName = ffHostGetMacProductNameWithHwModel(&host->name);
|
||||
if (productName)
|
||||
{
|
||||
ffStrbufDestroy(&host->family);
|
||||
ffStrbufInitMove(&host->family, &host->name);
|
||||
ffStrbufSetStatic(&host->name, productName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -72,5 +72,9 @@ const char* ffDetectHost(FFHostResult* host)
|
||||
ffCleanUpSmbiosValue(&host->family);
|
||||
}
|
||||
|
||||
#if _WIN32 && __x86_64__
|
||||
ffHostDetectMac(host);
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "fastfetch.h"
|
||||
#include "opengl.h"
|
||||
#include "common/io/io.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -140,6 +141,8 @@ static const char* detectByGlx(FFOpenGLResult* result)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(glx, data, XCloseDisplay);
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(glx, data, XFree);
|
||||
|
||||
FF_SUPPRESS_IO();
|
||||
|
||||
return glxHandleData(result, &data);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,10 @@ void ffOpenGLHandleResult(FFOpenGLResult* result, __typeof__(&glGetString) ffglG
|
||||
#if defined(FF_HAVE_EGL) || __has_include(<EGL/egl.h>)
|
||||
#include "common/io/io.h"
|
||||
|
||||
#define EGL_EGL_PROTOTYPES 1
|
||||
#define EGL_EGLEXT_PROTOTYPES 1
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
|
||||
typedef struct EGLData
|
||||
{
|
||||
@@ -102,9 +105,20 @@ static const char* eglHandleData(FFOpenGLResult* result, EGLData* data)
|
||||
if(!data->ffglGetString)
|
||||
return "eglGetProcAddress(glGetString) returned NULL";
|
||||
|
||||
data->display = data->ffeglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
if(data->display == EGL_NO_DISPLAY)
|
||||
return "eglGetDisplay returned EGL_NO_DISPLAY";
|
||||
#if EGL_VERSION_1_5
|
||||
PFNEGLGETPLATFORMDISPLAYEXTPROC ffeglGetPlatformDisplay = (PFNEGLGETPLATFORMDISPLAYEXTPROC) data->ffeglGetProcAddress("eglGetPlatformDisplay");
|
||||
if (ffeglGetPlatformDisplay)
|
||||
data->display = ffeglGetPlatformDisplay(EGL_PLATFORM_SURFACELESS_MESA, NULL, NULL);
|
||||
|
||||
if(!ffeglGetPlatformDisplay || data->display == EGL_NO_DISPLAY)
|
||||
#endif
|
||||
|
||||
{
|
||||
data->display = data->ffeglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
if(data->display == EGL_NO_DISPLAY)
|
||||
return "eglGetDisplay returned EGL_NO_DISPLAY";
|
||||
}
|
||||
|
||||
|
||||
EGLint major, minor;
|
||||
if(data->ffeglInitialize(data->display, &major, &minor) == EGL_FALSE)
|
||||
|
||||
@@ -52,6 +52,15 @@ FF_MAYBE_UNUSED static void getUbuntuFlavour(FFOSResult* result)
|
||||
if(!ffStrSet(xdgConfigDirs))
|
||||
return;
|
||||
|
||||
if(ffStrbufStartsWithS(&result->prettyName, "Linux Lite "))
|
||||
{
|
||||
ffStrbufSetS(&result->name, "Linux Lite");
|
||||
ffStrbufSetS(&result->id, "linuxlite");
|
||||
ffStrbufSetS(&result->idLike, "ubuntu");
|
||||
ffStrbufSetS(&result->versionID, result->prettyName.chars + strlen("Linux Lite "));
|
||||
return;
|
||||
}
|
||||
|
||||
if(ffStrContains(xdgConfigDirs, "kde") || ffStrContains(xdgConfigDirs, "plasma") || ffStrContains(xdgConfigDirs, "kubuntu"))
|
||||
{
|
||||
ffStrbufSetS(&result->name, "Kubuntu");
|
||||
@@ -166,6 +175,17 @@ FF_MAYBE_UNUSED static bool detectDebianDerived(FFOSResult* result)
|
||||
ffStrbufSetNS(&result->versionID, versionEnd - versionStart, result->prettyName.chars + versionStart);
|
||||
return true;
|
||||
}
|
||||
else if (ffStrbufStartsWithS(&result->prettyName, "Armbian-unofficial ")) // Unofficial Armbian image built from source
|
||||
{
|
||||
ffStrbufSetS(&result->name, "Armbian (custom build)");
|
||||
ffStrbufSetS(&result->id, "armbian");
|
||||
ffStrbufSetS(&result->idLike, "debian");
|
||||
ffStrbufClear(&result->versionID);
|
||||
uint32_t versionStart = ffStrbufFirstIndexC(&result->prettyName, ' ') + 1;
|
||||
uint32_t versionEnd = ffStrbufNextIndexC(&result->prettyName, versionStart, ' ');
|
||||
ffStrbufSetNS(&result->versionID, versionEnd - versionStart, result->prettyName.chars + versionStart);
|
||||
return true;
|
||||
}
|
||||
else if (ffStrbufStartsWithS(&result->name, "Loc-OS"))
|
||||
{
|
||||
ffStrbufSetS(&result->id, "locos");
|
||||
|
||||
@@ -37,9 +37,14 @@ const char* ffDetectWifi(FFlist* result)
|
||||
item->conn.channel = 0;
|
||||
item->conn.frequency = 0;
|
||||
|
||||
ffParsePropLines(ifconfig.chars, "status: ", &item->conn.status);
|
||||
if (!ffStrbufEqualS(&item->conn.status, "associated"))
|
||||
continue;
|
||||
|
||||
ffParsePropLines(ifconfig.chars, "ssid ", &item->conn.ssid);
|
||||
if (item->conn.ssid.length)
|
||||
{
|
||||
// This doesn't work for quoted SSID values
|
||||
uint32_t idx = ffStrbufFirstIndexS(&item->conn.ssid, " bssid ");
|
||||
if (idx < item->conn.ssid.length)
|
||||
{
|
||||
@@ -69,8 +74,6 @@ const char* ffDetectWifi(FFlist* result)
|
||||
ffStrbufPrependS(&item->conn.protocol, "802.");
|
||||
}
|
||||
}
|
||||
|
||||
ffParsePropLines(ifconfig.chars, "status: ", &item->conn.status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -285,7 +285,7 @@ static const char* detectWifiWithIoctls(FFWifiResult* item)
|
||||
{
|
||||
for(int i = 0; i < 6; ++i)
|
||||
ffStrbufAppendF(&item->conn.bssid, "%.2X:", (uint8_t) iwr.u.ap_addr.sa_data[i]);
|
||||
ffStrbufTrimRight(&item->conn.bssid, '-');
|
||||
ffStrbufTrimRight(&item->conn.bssid, ':');
|
||||
}
|
||||
|
||||
if(ioctl(sock, SIOCGIWRATE, &iwr) >= 0)
|
||||
|
||||
+54
-2
@@ -2,6 +2,7 @@
|
||||
#include "common/commandoption.h"
|
||||
#include "common/io/io.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/printing.h"
|
||||
#include "detection/version/version.h"
|
||||
#include "util/stringUtils.h"
|
||||
#include "util/mallocHelper.h"
|
||||
@@ -15,16 +16,65 @@
|
||||
#include "util/windows/getline.h"
|
||||
#endif
|
||||
|
||||
static void printCommandFormatHelpJson(void)
|
||||
{
|
||||
yyjson_mut_doc* doc = yyjson_mut_doc_new(NULL);
|
||||
yyjson_mut_val* root = yyjson_mut_obj(doc);
|
||||
yyjson_mut_doc_set_root(doc, root);
|
||||
|
||||
for (uint32_t i = 0; i <= 'Z' - 'A'; ++i)
|
||||
{
|
||||
for (FFModuleBaseInfo** modules = ffModuleInfos[i]; *modules; ++modules)
|
||||
{
|
||||
FFModuleBaseInfo* baseInfo = *modules;
|
||||
if (!baseInfo->formatArgs.count) continue;
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY type = ffStrbufCreateS(baseInfo->name);
|
||||
ffStrbufLowerCase(&type);
|
||||
ffStrbufAppendS(&type, "Format");
|
||||
|
||||
yyjson_mut_val* obj = yyjson_mut_obj(doc);
|
||||
if (yyjson_mut_obj_add(root, yyjson_mut_strbuf(doc, &type), obj))
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY content = ffStrbufCreateF("Output format of the module `%s`. See `-h format` for formatting syntax\n", baseInfo->name);
|
||||
for (unsigned i = 0; i < baseInfo->formatArgs.count; i++)
|
||||
{
|
||||
const FFModuleFormatArg* arg = &baseInfo->formatArgs.args[i];
|
||||
ffStrbufAppendF(&content, " %u. {%s}: %s\n", i + 1, arg->name, arg->desc);
|
||||
}
|
||||
ffStrbufTrimRight(&content, '\n');
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "description", &content);
|
||||
yyjson_mut_obj_add_str(doc, obj, "type", "string");
|
||||
}
|
||||
}
|
||||
}
|
||||
yyjson_mut_write_fp(stdout, doc, YYJSON_WRITE_PRETTY, NULL, NULL);
|
||||
putchar('\n');
|
||||
yyjson_mut_doc_free(doc);
|
||||
}
|
||||
|
||||
static void printCommandFormatHelp(const char* command)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY type = ffStrbufCreateNS((uint32_t) (strlen(command) - strlen("-format")), command);
|
||||
ffStrbufLowerCase(&type);
|
||||
for (FFModuleBaseInfo** modules = ffModuleInfos[toupper(command[0]) - 'A']; *modules; ++modules)
|
||||
{
|
||||
FFModuleBaseInfo* baseInfo = *modules;
|
||||
if (ffStrbufIgnCaseEqualS(&type, baseInfo->name))
|
||||
{
|
||||
if (baseInfo->printHelpFormat)
|
||||
baseInfo->printHelpFormat();
|
||||
if (baseInfo->formatArgs.count > 0)
|
||||
{
|
||||
printf("--%s-format:\n", type.chars);
|
||||
printf("Sets the format string for %s output.\n", baseInfo->name);
|
||||
puts("To see how a format string is constructed, take a look at \"fastfetch --help format\".");
|
||||
puts("The following values are passed:");
|
||||
|
||||
for (unsigned i = 0; i < baseInfo->formatArgs.count; i++)
|
||||
{
|
||||
const FFModuleFormatArg* arg = &baseInfo->formatArgs.args[i];
|
||||
printf("%16s {%u}: %s\n", arg->name, i + 1, arg->desc);
|
||||
}
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "Error: Module '%s' doesn't support output formatting\n", baseInfo->name);
|
||||
return;
|
||||
@@ -252,6 +302,8 @@ static void printCommandHelp(const char* command)
|
||||
puts(FASTFETCH_DATATEXT_HELP_COLOR);
|
||||
else if(ffStrEqualsIgnCase(command, "format"))
|
||||
puts(FASTFETCH_DATATEXT_HELP_FORMAT);
|
||||
else if(ffStrEqualsIgnCase(command, "format-json"))
|
||||
printCommandFormatHelpJson();
|
||||
else if(ffCharIsEnglishAlphabet(command[0]) && ffStrEndsWithIgnCase(command, "-format")) // <module>-format
|
||||
printCommandFormatHelp(command);
|
||||
else if(!printSpecificCommandHelp(command))
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
$2_,met$$$$$$$$$$gg.
|
||||
,g$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$P.
|
||||
,g$$$$P" """Y$$$$.".
|
||||
,$$$$P' `$$$$$$.
|
||||
$2_,met$$$$$$$$$$gg.
|
||||
,g$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$P.
|
||||
,g$$$$P"" """Y$$$$.".
|
||||
,$$$$P' `$$$$$$.
|
||||
',$$$$P ,ggs. `$$$$b:
|
||||
`d$$$$' ,$P"' $1.$2 $$$$$$
|
||||
$$$$P d$' $1,$2 $$$$$$P
|
||||
$$$$: $$. $1-$2 ,d$$$$'
|
||||
$$$$P d$' $1,$2 $$$$P
|
||||
$$$$: $$$. $1-$2 ,d$$$$'
|
||||
$$$$; Y$b._ _,d$P'
|
||||
Y$$$$. $1`.$2`"Y$$$$$$$$P"'
|
||||
`$$$$b $1"-.__
|
||||
$2`Y$$$$
|
||||
$2`Y$$$$b
|
||||
`Y$$$$.
|
||||
`$$$$b.
|
||||
`Y$$$$b.
|
||||
`"Y$$b._
|
||||
`"""
|
||||
`"Y$$b._
|
||||
`""""
|
||||
@@ -1,20 +1,20 @@
|
||||
,xXc
|
||||
.l0MMMMMO
|
||||
.kNMMMMMWMMMN,
|
||||
KMMMMMMKMMMMMMo
|
||||
'MMMMMMNKMMMMMM:
|
||||
kMMMMMMOMMMMMMO
|
||||
.MMMMMMX0MMMMMW.
|
||||
oMMMMMMxWMMMMM:
|
||||
WMMMMMNkMMMMMO
|
||||
:MMMMMMOXMMMMW
|
||||
.0MMMMMxMMMMM;
|
||||
:;cKMMWxMMMMO
|
||||
'MMWMMXOMMMMl
|
||||
kMMMMKOMMMMMX:
|
||||
.WMMMMKOWMMM0c
|
||||
lMMMMMWO0MNd:'
|
||||
oollXMKXoxl;.
|
||||
':. .: .'
|
||||
..
|
||||
.kNMMMMM$2W$1MMMN,
|
||||
KMMMMMM$2K$1MMMMMMo
|
||||
'MMMMMMN$2K$1MMMMMM:
|
||||
kMMMMMM$2O$1MMMMMMO
|
||||
.MMMMMM$20$1XMMMMMW.
|
||||
oMMMMM$2x$1MMMMMMM:
|
||||
WMMMMM$2x$1MMMMMMO
|
||||
:MMMMMM$2O$1XMMMMW
|
||||
.0MMMMM$2x$1MMMMM;
|
||||
:;cKMMW$2x$1MMMMO
|
||||
'MMWMMX$2O$1MMMMl
|
||||
kMMMMK$2O$1MMMMMX:
|
||||
.WMMMMK$2O$1WMMM0c
|
||||
lMMMMMW$2O$1WMNd:'
|
||||
oollXMK$2o$1Xxl;.
|
||||
':. .:$2 .$1'
|
||||
$2..
|
||||
.
|
||||
@@ -1,7 +1,7 @@
|
||||
${c1} /\\
|
||||
/ \\
|
||||
/ ${c2}/ ${c1}/
|
||||
> ${c2}/ ${c1}/
|
||||
/\\
|
||||
/ \\
|
||||
/ ${c2}/ ${c1}/
|
||||
> ${c2}/ ${c1}/
|
||||
\\ ${c2}\\ ${c1}\\
|
||||
\\_${c2}\\${c1}_\\
|
||||
${c2} \\
|
||||
${c2} \\
|
||||
@@ -0,0 +1,18 @@
|
||||
,dKNWWNKOxo;.
|
||||
;xKXOdoloOWMWX0d:.
|
||||
.dNNd' cNMMMMNKOx;.
|
||||
.dWNo .:oxO000KXKl.
|
||||
.OMNl .....
|
||||
oNMXd,.
|
||||
.lKWMNKkdollccc:::;;;,'..
|
||||
.;ox0KNWWMMMMMMMMWWWWNK0xl,.
|
||||
..,;:ccloodxO0KNWMMMMNOc.
|
||||
.';lxKWMMWk'
|
||||
..,:ccc:,. .oXMMMO
|
||||
.:d0NWWWWWMWXOo,. .,cc:;,,'..oWMMW
|
||||
.c0WW0xl:;,;cd0NMNO:'..ldl;. .'.:XMMM
|
||||
xWMKc. .;OWMWX0xl. .dWMMK
|
||||
WMWd. .oKWMMXx, .dNMMXc
|
||||
NMMK:. ..:oxo:oOXMMNOdc:;;cxKWMWO;
|
||||
;kXWN0xooodkOOko;. .lONMMMMWWMMWKx;.
|
||||
,okKXXXKOxc'. .:kKWMMWXOl'
|
||||
@@ -0,0 +1,14 @@
|
||||
@@@@@@@@@@@@
|
||||
@@@@@@@@@@@@@@@@@@
|
||||
@@@@@@@@@@@@@@@@@@@@@@
|
||||
@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
@@@@@@@@@*=+*%@@@@@@@@@@@@
|
||||
@@@@@@@@@@: :#@@@@@@@@@@
|
||||
@@@@@@@@@# -#@@@@@@@@
|
||||
@@%###*=. :=*#@@@@
|
||||
@@= =@@
|
||||
@@= -@@
|
||||
@@*: :*@@
|
||||
@%*=: :=*@@
|
||||
@@@%%##%%@@@
|
||||
+21
-4
@@ -2477,10 +2477,10 @@ static const FFlogo L[] = {
|
||||
.names = {"LinuxLite", "Linux Lite", "linux_lite"},
|
||||
.lines = FASTFETCH_DATATEXT_LOGO_LINUXLITE,
|
||||
.colors = {
|
||||
FF_COLOR_FG_YELLOW,
|
||||
FF_COLOR_FG_GREEN,
|
||||
FF_COLOR_FG_WHITE,
|
||||
},
|
||||
.colorKeys = FF_COLOR_FG_YELLOW,
|
||||
.colorKeys = FF_COLOR_FG_GREEN,
|
||||
.colorTitle = FF_COLOR_FG_WHITE,
|
||||
},
|
||||
// LinuxLightSmall
|
||||
@@ -2489,10 +2489,10 @@ static const FFlogo L[] = {
|
||||
.type = FF_LOGO_LINE_TYPE_SMALL_BIT,
|
||||
.lines = FASTFETCH_DATATEXT_LOGO_LINUXLITE_SMALL,
|
||||
.colors = {
|
||||
FF_COLOR_FG_YELLOW,
|
||||
FF_COLOR_FG_BLUE,
|
||||
FF_COLOR_FG_WHITE,
|
||||
},
|
||||
.colorKeys = FF_COLOR_FG_YELLOW,
|
||||
.colorKeys = FF_COLOR_FG_BLUE,
|
||||
.colorTitle = FF_COLOR_FG_WHITE,
|
||||
},
|
||||
// LinuxMint
|
||||
@@ -4052,6 +4052,14 @@ static const FFlogo S[] = {
|
||||
FF_COLOR_FG_RED,
|
||||
},
|
||||
},
|
||||
// Serpent OS
|
||||
{
|
||||
.names = {"Serpent OS"},
|
||||
.lines = FASTFETCH_DATATEXT_LOGO_SERPENT_OS,
|
||||
.colors = {
|
||||
FF_COLOR_FG_WHITE,
|
||||
},
|
||||
},
|
||||
// Semc
|
||||
{
|
||||
.names = {"semc"},
|
||||
@@ -4627,6 +4635,15 @@ static const FFlogo U[] = {
|
||||
FF_COLOR_FG_WHITE,
|
||||
},
|
||||
},
|
||||
// Ultramarine Small
|
||||
{
|
||||
.names = {"Ultramarine_small"},
|
||||
.lines = FASTFETCH_DATATEXT_LOGO_ULTRAMARINE_SMALL,
|
||||
.colors = {
|
||||
FF_COLOR_FG_BLUE,
|
||||
FF_COLOR_FG_WHITE,
|
||||
},
|
||||
},
|
||||
// Unifi
|
||||
{
|
||||
.names = {"Unifi"},
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
#include "modules/battery/battery.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_BATTERY_NUM_FORMAT_ARGS 14
|
||||
|
||||
static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uint8_t index)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
|
||||
@@ -22,7 +20,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
|
||||
else
|
||||
{
|
||||
ffStrbufClear(&key);
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 2, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(index, "index"),
|
||||
FF_FORMAT_ARG(result->modelName, "name"),
|
||||
}));
|
||||
@@ -105,7 +103,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
|
||||
FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate();
|
||||
ffTempsAppendNum(result->temperature, &tempStr, options->tempConfig, &options->moduleArgs);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BATTERY_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result->manufacturer, "manufacturer"),
|
||||
FF_FORMAT_ARG(result->modelName, "model-name"),
|
||||
FF_FORMAT_ARG(result->technology, "technology"),
|
||||
@@ -270,39 +268,35 @@ void ffGenerateBatteryJsonResult(FFBatteryOptions* options, yyjson_mut_doc* doc,
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintBatteryHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BATTERY_MODULE_NAME, "{4} ({12} hours {13} mins) [{5}]", FF_BATTERY_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Battery manufacturer - manufacturer",
|
||||
"Battery model name - model-name",
|
||||
"Battery technology - technology",
|
||||
"Battery capacity (percentage num) - capacity",
|
||||
"Battery status - status",
|
||||
"Battery temperature (formatted) - temperature",
|
||||
"Battery cycle count - cycle-count",
|
||||
"Battery serial number - serial",
|
||||
"Battery manufactor date - manufacture-date",
|
||||
"Battery capacity (percentage bar) - capacity-bar",
|
||||
"Battery time remaining days - time-days",
|
||||
"Battery time remaining hours - time-hours",
|
||||
"Battery time remaining minutes - time-minutes",
|
||||
"Battery time remaining seconds - time-seconds",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_BATTERY_MODULE_NAME,
|
||||
.description = "Print battery capacity, status, etc",
|
||||
.parseCommandOptions = (void*) ffParseBatteryCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseBatteryJsonObject,
|
||||
.printModule = (void*) ffPrintBattery,
|
||||
.generateJsonResult = (void*) ffGenerateBatteryJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateBatteryJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Battery manufacturer", "manufacturer"},
|
||||
{"Battery model name", "model-name"},
|
||||
{"Battery technology", "technology"},
|
||||
{"Battery capacity (percentage num)", "capacity"},
|
||||
{"Battery status", "status"},
|
||||
{"Battery temperature (formatted)", "temperature"},
|
||||
{"Battery cycle count", "cycle-count"},
|
||||
{"Battery serial number", "serial"},
|
||||
{"Battery manufactor date", "manufacture-date"},
|
||||
{"Battery capacity (percentage bar)", "capacity-bar"},
|
||||
{"Battery time remaining days", "time-days"},
|
||||
{"Battery time remaining hours", "time-hours"},
|
||||
{"Battery time remaining minutes", "time-minutes"},
|
||||
{"Battery time remaining seconds", "time-seconds"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitBatteryOptions(FFBatteryOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_BATTERY_MODULE_NAME,
|
||||
"Print battery capacity, status, etc",
|
||||
ffParseBatteryCommandOptions,
|
||||
ffParseBatteryJsonObject,
|
||||
ffPrintBattery,
|
||||
ffGenerateBatteryJsonResult,
|
||||
ffPrintBatteryHelpFormat,
|
||||
ffGenerateBatteryJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
options->temp = false;
|
||||
options->tempConfig = (FFColorRangeConfig) { 60, 80 };
|
||||
|
||||
+19
-25
@@ -4,8 +4,6 @@
|
||||
#include "modules/bios/bios.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_BIOS_NUM_FORMAT_ARGS 5
|
||||
|
||||
void ffPrintBios(FFBiosOptions* options)
|
||||
{
|
||||
FFBiosResult bios;
|
||||
@@ -43,7 +41,7 @@ void ffPrintBios(FFBiosOptions* options)
|
||||
else
|
||||
{
|
||||
ffStrbufClear(&key);
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 2, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(bios.type, "type"),
|
||||
FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"),
|
||||
}));
|
||||
@@ -60,7 +58,7 @@ void ffPrintBios(FFBiosOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BIOS_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(bios.date, "date"),
|
||||
FF_FORMAT_ARG(bios.release, "release"),
|
||||
FF_FORMAT_ARG(bios.vendor, "vendor"),
|
||||
@@ -144,30 +142,26 @@ exit:
|
||||
ffStrbufDestroy(&bios.type);
|
||||
}
|
||||
|
||||
void ffPrintBiosHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BIOS_MODULE_NAME, "{4} ({2})", FF_BIOS_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"bios date - date",
|
||||
"bios release - release",
|
||||
"bios vendor - vendor",
|
||||
"bios version - version",
|
||||
"firmware type - type",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_BIOS_MODULE_NAME,
|
||||
.description = "Print information of 1st-stage bootloader (name, version, release date, etc)",
|
||||
.parseCommandOptions = (void*) ffParseBiosCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseBiosJsonObject,
|
||||
.printModule = (void*) ffPrintBios,
|
||||
.generateJsonResult = (void*) ffGenerateBiosJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateBiosJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Bios date", "date"},
|
||||
{"Bios release", "release"},
|
||||
{"Bios vendor", "vendor"},
|
||||
{"Bios version", "version"},
|
||||
{"Firmware type", "type"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitBiosOptions(FFBiosOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_BIOS_MODULE_NAME,
|
||||
"Print information of 1st-stage bootloader (name, version, release date, etc)",
|
||||
ffParseBiosCommandOptions,
|
||||
ffParseBiosJsonObject,
|
||||
ffPrintBios,
|
||||
ffGenerateBiosJsonResult,
|
||||
ffPrintBiosHelpFormat,
|
||||
ffGenerateBiosJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
#include "modules/bluetooth/bluetooth.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_BLUETOOTH_NUM_FORMAT_ARGS 6
|
||||
|
||||
static void printDevice(FFBluetoothOptions* options, const FFBluetoothResult* device, uint8_t index)
|
||||
{
|
||||
FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type;
|
||||
@@ -47,7 +45,7 @@ static void printDevice(FFBluetoothOptions* options, const FFBluetoothResult* de
|
||||
if(percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
ffPercentAppendBar(&percentageBar, device->battery, options->percent, &options->moduleArgs);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BLUETOOTH_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(device->name, "name"),
|
||||
FF_FORMAT_ARG(device->address, "address"),
|
||||
FF_FORMAT_ARG(device->type, "type"),
|
||||
@@ -188,31 +186,27 @@ void ffGenerateBluetoothJsonResult(FF_MAYBE_UNUSED FFBluetoothOptions* options,
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintBluetoothHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BLUETOOTH_MODULE_NAME, "{1} ({4})", FF_BLUETOOTH_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Name - device name",
|
||||
"Address - remote device address",
|
||||
"Type - type",
|
||||
"Battery percentage number - battery-percentage",
|
||||
"Is connected - connected",
|
||||
"Battery percentage bar - battery-percentage-bar",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_BLUETOOTH_MODULE_NAME,
|
||||
.description = "List (connected) bluetooth devices",
|
||||
.parseCommandOptions = (void*) ffParseBluetoothCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseBluetoothJsonObject,
|
||||
.printModule = (void*) ffPrintBluetooth,
|
||||
.generateJsonResult = (void*) ffGenerateBluetoothJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateBluetoothJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Name", "name"},
|
||||
{"Address", "address"},
|
||||
{"Type", "type"},
|
||||
{"Battery percentage number", "battery-percentage"},
|
||||
{"Is connected", "connected"},
|
||||
{"Battery percentage bar", "battery-percentage-bar"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitBluetoothOptions(FFBluetoothOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_BLUETOOTH_MODULE_NAME,
|
||||
"List (connected) bluetooth devices",
|
||||
ffParseBluetoothCommandOptions,
|
||||
ffParseBluetoothJsonObject,
|
||||
ffPrintBluetooth,
|
||||
ffGenerateBluetoothJsonResult,
|
||||
ffPrintBluetoothHelpFormat,
|
||||
ffGenerateBluetoothJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
options->showDisconnected = false;
|
||||
options->percent = (FFPercentageModuleConfig) { 50, 20, 0 };
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "modules/bluetoothradio/bluetoothradio.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_BLUETOOTHRADIO_NUM_FORMAT_ARGS 8
|
||||
#define FF_BLUETOOTHRADIO_DISPLAY_NAME "Bluetooth Radio"
|
||||
|
||||
static void printDevice(FFBluetoothRadioOptions* options, const FFBluetoothRadioResult* radio, uint8_t index)
|
||||
@@ -17,7 +16,7 @@ static void printDevice(FFBluetoothRadioOptions* options, const FFBluetoothRadio
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 3, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(index, "index"),
|
||||
FF_FORMAT_ARG(radio->name, "name"),
|
||||
FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"),
|
||||
@@ -55,7 +54,7 @@ static void printDevice(FFBluetoothRadioOptions* options, const FFBluetoothRadio
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BLUETOOTHRADIO_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(radio->name, "name"),
|
||||
FF_FORMAT_ARG(radio->address, "address"),
|
||||
FF_FORMAT_ARG(radio->lmpVersion, "lmp-version"),
|
||||
@@ -181,33 +180,29 @@ void ffGenerateBluetoothRadioJsonResult(FF_MAYBE_UNUSED FFBluetoothRadioOptions*
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintBluetoothRadioHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BLUETOOTHRADIO_MODULE_NAME, "Bluetooth {5} ({6})", FF_BLUETOOTHRADIO_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Radio name for discovering - name",
|
||||
"Address - local radio address",
|
||||
"LMP version - lmp-version",
|
||||
"LMP subversion - lmp-subversion",
|
||||
"Bluetooth version - version",
|
||||
"Vendor - vendor",
|
||||
"Discoverable - discoverable",
|
||||
"Connectable / Pairable - connectable",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_BLUETOOTHRADIO_MODULE_NAME,
|
||||
.description = "List bluetooth radios width supported version and vendor",
|
||||
.parseCommandOptions = (void*) ffParseBluetoothRadioCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseBluetoothRadioJsonObject,
|
||||
.printModule = (void*) ffPrintBluetoothRadio,
|
||||
.generateJsonResult = (void*) ffGenerateBluetoothRadioJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateBluetoothRadioJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Radio name for discovering", "name"},
|
||||
{"Address", "address"},
|
||||
{"LMP version", "lmp-version"},
|
||||
{"LMP subversion", "lmp-subversion"},
|
||||
{"Bluetooth version", "version"},
|
||||
{"Vendor", "vendor"},
|
||||
{"Discoverable", "discoverable"},
|
||||
{"Connectable / Pairable", "connectable"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitBluetoothRadioOptions(FFBluetoothRadioOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_BLUETOOTHRADIO_MODULE_NAME,
|
||||
"List bluetooth radios width supported version and vendor",
|
||||
ffParseBluetoothRadioCommandOptions,
|
||||
ffParseBluetoothRadioJsonObject,
|
||||
ffPrintBluetoothRadio,
|
||||
ffGenerateBluetoothRadioJsonResult,
|
||||
ffPrintBluetoothRadioHelpFormat,
|
||||
ffGenerateBluetoothRadioJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+17
-23
@@ -4,8 +4,6 @@
|
||||
#include "modules/board/board.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_BOARD_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintBoard(FFBoardOptions* options)
|
||||
{
|
||||
FFBoardResult result;
|
||||
@@ -37,7 +35,7 @@ void ffPrintBoard(FFBoardOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BOARD_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result.name, "name"),
|
||||
FF_FORMAT_ARG(result.vendor, "vendor"),
|
||||
FF_FORMAT_ARG(result.version, "version"),
|
||||
@@ -122,29 +120,25 @@ exit:
|
||||
ffStrbufDestroy(&board.serial);
|
||||
}
|
||||
|
||||
void ffPrintBoardHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BOARD_MODULE_NAME, "{1} ({3})", FF_BOARD_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"board name - name",
|
||||
"board vendor - vendor",
|
||||
"board version - version",
|
||||
"board serial number - serial",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_BOARD_MODULE_NAME,
|
||||
.description = "Print motherboard name and other info",
|
||||
.parseCommandOptions = (void*) ffParseBoardCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseBoardJsonObject,
|
||||
.printModule = (void*) ffPrintBoard,
|
||||
.generateJsonResult = (void*) ffGenerateBoardJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateBoardJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Board name", "name"},
|
||||
{"Board vendor", "vendor"},
|
||||
{"Board version", "version"},
|
||||
{"Board serial number", "serial"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitBoardOptions(FFBoardOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_BOARD_MODULE_NAME,
|
||||
"Print motherboard name and other info",
|
||||
ffParseBoardCommandOptions,
|
||||
ffParseBoardJsonObject,
|
||||
ffPrintBoard,
|
||||
ffGenerateBoardJsonResult,
|
||||
ffPrintBoardHelpFormat,
|
||||
ffGenerateBoardJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include "modules/bootmgr/bootmgr.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_BOOTMGR_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintBootmgr(FFBootmgrOptions* options)
|
||||
{
|
||||
FFBootmgrResult bootmgr = {
|
||||
@@ -39,7 +37,7 @@ void ffPrintBootmgr(FFBootmgrOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_BOOTMGR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BOOTMGR_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_BOOTMGR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(bootmgr.name, "name"),
|
||||
FF_FORMAT_ARG(bootmgr.firmware, "firmware-path"),
|
||||
FF_FORMAT_ARG(firmwareName, "firmware-name"),
|
||||
@@ -111,29 +109,25 @@ exit:
|
||||
ffStrbufDestroy(&bootmgr.firmware);
|
||||
}
|
||||
|
||||
void ffPrintBootmgrHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BOOTMGR_MODULE_NAME, "{4} ({2})", FF_BOOTMGR_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Name / description - name",
|
||||
"Firmware file path - firmware-path",
|
||||
"Firmware file name - firmware-name",
|
||||
"Is secure boot enabled - secure-boot",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_BOOTMGR_MODULE_NAME,
|
||||
.description = "Print information of 2nd-stage bootloader (name, firmware, etc)",
|
||||
.parseCommandOptions = (void*) ffParseBootmgrCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseBootmgrJsonObject,
|
||||
.printModule = (void*) ffPrintBootmgr,
|
||||
.generateJsonResult = (void*) ffGenerateBootmgrJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateBootmgrJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Name / description", "name"},
|
||||
{"Firmware file path", "firmware-path"},
|
||||
{"Firmware file name", "firmware-name"},
|
||||
{"Is secure boot enabled", "secure-boot"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitBootmgrOptions(FFBootmgrOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_BOOTMGR_MODULE_NAME,
|
||||
"Print information of 2nd-stage bootloader (name, firmware, etc)",
|
||||
ffParseBootmgrCommandOptions,
|
||||
ffParseBootmgrJsonObject,
|
||||
ffPrintBootmgr,
|
||||
ffGenerateBootmgrJsonResult,
|
||||
ffPrintBootmgrHelpFormat,
|
||||
ffGenerateBootmgrJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -16,19 +16,17 @@ void ffParseBreakJsonObject(FF_MAYBE_UNUSED FFBreakOptions* options, FF_MAYBE_UN
|
||||
{
|
||||
}
|
||||
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_BREAK_MODULE_NAME,
|
||||
.description = "Print a empty line",
|
||||
.parseCommandOptions = (void*) ffParseBreakCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseBreakJsonObject,
|
||||
.printModule = (void*) ffPrintBreak,
|
||||
};
|
||||
|
||||
void ffInitBreakOptions(FF_MAYBE_UNUSED FFBreakOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_BREAK_MODULE_NAME,
|
||||
"Print a empty line",
|
||||
ffParseBreakCommandOptions,
|
||||
ffParseBreakJsonObject,
|
||||
ffPrintBreak,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
}
|
||||
|
||||
void ffDestroyBreakOptions(FF_MAYBE_UNUSED FFBreakOptions* options)
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
#include "modules/brightness/brightness.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_BRIGHTNESS_NUM_FORMAT_ARGS 6
|
||||
|
||||
void ffPrintBrightness(FFBrightnessOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFBrightnessResult));
|
||||
@@ -57,7 +55,7 @@ void ffPrintBrightness(FFBrightnessOptions* options)
|
||||
else
|
||||
{
|
||||
uint32_t moduleIndex = result.length == 1 ? 0 : index + 1;
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 3, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(moduleIndex, "index"),
|
||||
FF_FORMAT_ARG(item->name, "name"),
|
||||
FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"),
|
||||
@@ -95,7 +93,7 @@ void ffPrintBrightness(FFBrightnessOptions* options)
|
||||
if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
ffPercentAppendBar(&valueBar, percent, options->percent, &options->moduleArgs);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BRIGHTNESS_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(valueNum, "percentage"),
|
||||
FF_FORMAT_ARG(item->name, "name"),
|
||||
FF_FORMAT_ARG(item->max, "max"),
|
||||
@@ -214,31 +212,27 @@ void ffGenerateBrightnessJsonResult(FF_MAYBE_UNUSED FFBrightnessOptions* options
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintBrightnessHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BRIGHTNESS_MODULE_NAME, "{1}", FF_BRIGHTNESS_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Screen brightness (percentage num) - percentage",
|
||||
"Screen name - name",
|
||||
"Maximum brightness value - max",
|
||||
"Minimum brightness value - min",
|
||||
"Current brightness value - current",
|
||||
"Screen brightness (percentage bar) - percentage-bar",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_BRIGHTNESS_MODULE_NAME,
|
||||
.description = "Print current brightness level of your monitors",
|
||||
.parseCommandOptions = (void*) ffParseBrightnessCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseBrightnessJsonObject,
|
||||
.printModule = (void*) ffPrintBrightness,
|
||||
.generateJsonResult = (void*) ffGenerateBrightnessJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateBrightnessJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Screen brightness (percentage num)", "percentage"},
|
||||
{"Screen name", "name"},
|
||||
{"Maximum brightness value", "max"},
|
||||
{"Minimum brightness value", "min"},
|
||||
{"Current brightness value", "current"},
|
||||
{"Screen brightness (percentage bar)", "percentage-bar"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitBrightnessOptions(FFBrightnessOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_BRIGHTNESS_MODULE_NAME,
|
||||
"Print current brightness level of your monitors",
|
||||
ffParseBrightnessCommandOptions,
|
||||
ffParseBrightnessJsonObject,
|
||||
ffPrintBrightness,
|
||||
ffGenerateBrightnessJsonResult,
|
||||
ffPrintBrightnessHelpFormat,
|
||||
ffGenerateBrightnessJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->ddcciSleep = 10;
|
||||
|
||||
+27
-33
@@ -5,8 +5,6 @@
|
||||
#include "modules/btrfs/btrfs.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_BTRFS_NUM_FORMAT_ARGS 13
|
||||
|
||||
static void printBtrfs(FFBtrfsOptions* options, FFBtrfsResult* result, uint8_t index)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
@@ -20,7 +18,7 @@ static void printBtrfs(FFBtrfsOptions* options, FFBtrfsResult* result, uint8_t i
|
||||
else
|
||||
{
|
||||
ffStrbufClear(&buffer);
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&buffer, &options->moduleArgs.key, 3, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&buffer, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(index, "index"),
|
||||
FF_FORMAT_ARG(result->name, "name"),
|
||||
FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"),
|
||||
@@ -80,7 +78,7 @@ static void printBtrfs(FFBtrfsOptions* options, FFBtrfsResult* result, uint8_t i
|
||||
FF_STRBUF_AUTO_DESTROY sectorSizePretty = ffStrbufCreate();
|
||||
ffParseSize(result->sectorSize, §orSizePretty);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(buffer.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BTRFS_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(buffer.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result->name, "name"),
|
||||
FF_FORMAT_ARG(result->uuid, "uuid"),
|
||||
FF_FORMAT_ARG(result->devices, "devices"),
|
||||
@@ -218,38 +216,34 @@ void ffGenerateBtrfsJsonResult(FF_MAYBE_UNUSED FFBtrfsOptions* options, yyjson_m
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintBtrfsHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BTRFS_MODULE_NAME, "{5} / {7} ({8}, {9} allocated)", FF_BTRFS_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Name / Label - name",
|
||||
"UUID - uuid",
|
||||
"Associated devices - devices",
|
||||
"Enabled features - features",
|
||||
"Size used - used",
|
||||
"Size allocated - allocated",
|
||||
"Size total - total",
|
||||
"Used percentage num - used-percentage",
|
||||
"Allocated percentage num - allocated-percentage",
|
||||
"Used percentage bar - used-percentage-bar",
|
||||
"Allocated percentage bar - allocated-percentage-bar",
|
||||
"Node size - node-size",
|
||||
"Sector size - sector-size",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_BTRFS_MODULE_NAME,
|
||||
.description = "Print Linux BTRFS volumes",
|
||||
.parseCommandOptions = (void*) ffParseBtrfsCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseBtrfsJsonObject,
|
||||
.printModule = (void*) ffPrintBtrfs,
|
||||
.generateJsonResult = (void*) ffGenerateBtrfsJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateBtrfsJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Name / Label", "name"},
|
||||
{"UUID", "uuid"},
|
||||
{"Associated devices", "devices"},
|
||||
{"Enabled features", "features"},
|
||||
{"Size used", "used"},
|
||||
{"Size allocated", "allocated"},
|
||||
{"Size total", "total"},
|
||||
{"Used percentage num", "used-percentage"},
|
||||
{"Allocated percentage num", "allocated-percentage"},
|
||||
{"Used percentage bar", "used-percentage-bar"},
|
||||
{"Allocated percentage bar", "allocated-percentage-bar"},
|
||||
{"Node size", "node-size"},
|
||||
{"Sector size", "sector-size"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitBtrfsOptions(FFBtrfsOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_BTRFS_MODULE_NAME,
|
||||
"Print BTRFS volumes",
|
||||
ffParseBtrfsCommandOptions,
|
||||
ffParseBtrfsJsonObject,
|
||||
ffPrintBtrfs,
|
||||
ffGenerateBtrfsJsonResult,
|
||||
ffPrintBtrfsHelpFormat,
|
||||
ffGenerateBtrfsJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
options->percent = (FFPercentageModuleConfig) { 50, 80, 0 };
|
||||
}
|
||||
|
||||
+19
-25
@@ -5,8 +5,6 @@
|
||||
#include "modules/camera/camera.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_CAMERA_NUM_FORMAT_ARGS 6
|
||||
|
||||
static void printDevice(FFCameraOptions* options, const FFCameraResult* device, uint8_t index)
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
@@ -27,7 +25,7 @@ static void printDevice(FFCameraOptions* options, const FFCameraResult* device,
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CAMERA_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CAMERA_NUM_FORMAT_ARGS, (((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CAMERA_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, (((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(device->name, "name"),
|
||||
FF_FORMAT_ARG(device->vendor, "vendor"),
|
||||
FF_FORMAT_ARG(device->colorspace, "colorspace"),
|
||||
@@ -136,31 +134,27 @@ void ffGenerateCameraJsonResult(FF_MAYBE_UNUSED FFCameraOptions* options, yyjson
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintCameraHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CAMERA_MODULE_NAME, "{1} ({4}px x {5}px)", FF_CAMERA_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Device name - name",
|
||||
"Vendor - vendor",
|
||||
"Color space - colorspace",
|
||||
"Identifier - id",
|
||||
"Width (in px) - width",
|
||||
"Height (in px) - height",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_CAMERA_MODULE_NAME,
|
||||
.description = "Print available cameras",
|
||||
.parseCommandOptions = (void*) ffParseCameraCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseCameraJsonObject,
|
||||
.printModule = (void*) ffPrintCamera,
|
||||
.generateJsonResult = (void*) ffGenerateCameraJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateCameraJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Device name", "name"},
|
||||
{"Vendor", "vendor"},
|
||||
{"Color space", "colorspace"},
|
||||
{"Identifier", "id"},
|
||||
{"Width (in px)", "width"},
|
||||
{"Height (in px)", "height"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitCameraOptions(FFCameraOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_CAMERA_MODULE_NAME,
|
||||
"Print available cameras",
|
||||
ffParseCameraCommandOptions,
|
||||
ffParseCameraJsonObject,
|
||||
ffPrintCamera,
|
||||
ffGenerateCameraJsonResult,
|
||||
ffPrintCameraHelpFormat,
|
||||
ffGenerateCameraJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include "modules/chassis/chassis.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_CHASSIS_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintChassis(FFChassisOptions* options)
|
||||
{
|
||||
FFChassisResult result;
|
||||
@@ -38,7 +36,7 @@ void ffPrintChassis(FFChassisOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CHASSIS_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result.type, "type"),
|
||||
FF_FORMAT_ARG(result.vendor, "vendor"),
|
||||
FF_FORMAT_ARG(result.version, "version"),
|
||||
@@ -123,29 +121,25 @@ exit:
|
||||
ffStrbufDestroy(&result.serial);
|
||||
}
|
||||
|
||||
void ffPrintChassisHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CHASSIS_MODULE_NAME, "{1}", FF_CHASSIS_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"chassis type - type",
|
||||
"chassis vendor - vendor",
|
||||
"chassis version - version",
|
||||
"chassis serial number - serial",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_CHASSIS_MODULE_NAME,
|
||||
.description = "Print chassis type (desktop, laptop, etc)",
|
||||
.parseCommandOptions = (void*) ffParseChassisCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseChassisJsonObject,
|
||||
.printModule = (void*) ffPrintChassis,
|
||||
.generateJsonResult = (void*) ffGenerateChassisJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateChassisJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Chassis type", "type"},
|
||||
{"Chassis vendor", "vendor"},
|
||||
{"Chassis version", "version"},
|
||||
{"Chassis serial number", "serial"},
|
||||
})),
|
||||
};
|
||||
|
||||
void ffInitChassisOptions(FFChassisOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_CHASSIS_MODULE_NAME,
|
||||
"Print chassis type (desktop, laptop, etc)",
|
||||
ffParseChassisCommandOptions,
|
||||
ffParseChassisJsonObject,
|
||||
ffPrintChassis,
|
||||
ffGenerateChassisJsonResult,
|
||||
ffPrintChassisHelpFormat,
|
||||
ffGenerateChassisJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+10
-11
@@ -291,19 +291,18 @@ void ffGenerateColorsJsonConfig(FFColorsOptions* options, yyjson_mut_doc* doc, y
|
||||
}
|
||||
}
|
||||
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_COLORS_MODULE_NAME,
|
||||
.description = "Print some colored blocks",
|
||||
.parseCommandOptions = (void*) ffParseColorsCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseColorsJsonObject,
|
||||
.printModule = (void*) ffPrintColors,
|
||||
.generateJsonConfig = (void*) ffGenerateColorsJsonConfig,
|
||||
};
|
||||
|
||||
void ffInitColorsOptions(FFColorsOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_COLORS_MODULE_NAME,
|
||||
"Print some colored blocks",
|
||||
ffParseColorsCommandOptions,
|
||||
ffParseColorsJsonObject,
|
||||
ffPrintColors,
|
||||
NULL,
|
||||
NULL,
|
||||
ffGenerateColorsJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
ffStrbufSetStatic(&options->moduleArgs.key, " ");
|
||||
options->symbol = FF_COLORS_SYMBOL_BACKGROUND;
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include "modules/command/command.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_COMMAND_NUM_FORMAT_ARGS 1
|
||||
|
||||
void ffPrintCommand(FFCommandOptions* options)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY result = ffStrbufCreate();
|
||||
@@ -39,7 +37,7 @@ void ffPrintCommand(FFCommandOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_COMMAND_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(result, "result")
|
||||
}));
|
||||
}
|
||||
@@ -154,26 +152,22 @@ void ffGenerateCommandJsonResult(FF_MAYBE_UNUSED FFCommandOptions* options, yyjs
|
||||
yyjson_mut_obj_add_strbuf(doc, module, "result", &result);
|
||||
}
|
||||
|
||||
void ffPrintCommandHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_COMMAND_MODULE_NAME, "{1}", FF_COMMAND_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Command result - result"
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_COMMAND_MODULE_NAME,
|
||||
.description = "Run custom shell scripts",
|
||||
.parseCommandOptions = (void*) ffParseCommandCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseCommandJsonObject,
|
||||
.printModule = (void*) ffPrintCommand,
|
||||
.generateJsonResult = (void*) ffGenerateCommandJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateCommandJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Command result", "result"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitCommandOptions(FFCommandOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_COMMAND_MODULE_NAME,
|
||||
"Running custom shell scripts",
|
||||
ffParseCommandCommandOptions,
|
||||
ffParseCommandJsonObject,
|
||||
ffPrintCommand,
|
||||
ffGenerateCommandJsonResult,
|
||||
ffPrintCommandHelpFormat,
|
||||
ffGenerateCommandJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
ffStrbufInitStatic(&options->shell,
|
||||
|
||||
+23
-29
@@ -6,8 +6,6 @@
|
||||
#include "modules/cpu/cpu.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_CPU_NUM_FORMAT_ARGS 10
|
||||
|
||||
static int sortCores(const FFCPUCore* a, const FFCPUCore* b)
|
||||
{
|
||||
return (int)b->freq - (int)a->freq;
|
||||
@@ -104,7 +102,7 @@ void ffPrintCPU(FFCPUOptions* options)
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate();
|
||||
ffTempsAppendNum(cpu.temperature, &tempStr, options->tempConfig, &options->moduleArgs);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CPU_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(cpu.name, "name"),
|
||||
FF_FORMAT_ARG(cpu.vendor, "vendor"),
|
||||
FF_FORMAT_ARG(cpu.coresPhysical, "cores-physical"),
|
||||
@@ -241,35 +239,31 @@ void ffGenerateCPUJsonResult(FFCPUOptions* options, yyjson_mut_doc* doc, yyjson_
|
||||
ffStrbufDestroy(&cpu.vendor);
|
||||
}
|
||||
|
||||
void ffPrintCPUHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CPU_MODULE_NAME, "{1} ({5}) @ {7} GHz", FF_CPU_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Name - name",
|
||||
"Vendor - vendor",
|
||||
"Physical core count - cores-physical",
|
||||
"Logical core count - cores-logical",
|
||||
"Online core count - cores-online",
|
||||
"Base frequency (formatted) - freq-base",
|
||||
"Max frequency (formatted) - freq-max",
|
||||
"Temperature (formatted) - temperature",
|
||||
"Logical core count grouped by frequency - core-types",
|
||||
"Processor package count - packages",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_CPU_MODULE_NAME,
|
||||
.description = "Print CPU name, frequency, etc",
|
||||
.parseCommandOptions = (void*) ffParseCPUCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseCPUJsonObject,
|
||||
.printModule = (void*) ffPrintCPU,
|
||||
.generateJsonResult = (void*) ffGenerateCPUJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateCPUJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Name", "name"},
|
||||
{"Vendor", "vendor"},
|
||||
{"Physical core count", "cores-physical"},
|
||||
{"Logical core count", "cores-logical"},
|
||||
{"Online core count", "cores-online"},
|
||||
{"Base frequency (formatted)", "freq-base"},
|
||||
{"Max frequency (formatted)", "freq-max"},
|
||||
{"Temperature (formatted)", "temperature"},
|
||||
{"Logical core count grouped by frequency", "core-types"},
|
||||
{"Processor package count", "packages"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitCPUOptions(FFCPUOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_CPU_MODULE_NAME,
|
||||
"Print CPU name, frequency, etc",
|
||||
ffParseCPUCommandOptions,
|
||||
ffParseCPUJsonObject,
|
||||
ffPrintCPU,
|
||||
ffGenerateCPUJsonResult,
|
||||
ffPrintCPUHelpFormat,
|
||||
ffGenerateCPUJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
options->temp = false;
|
||||
options->tempConfig = (FFColorRangeConfig) { 60, 80 };
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_CPUCACHE_DISPLAY_NAME "CPU Cache"
|
||||
#define FF_CPUCACHE_NUM_FORMAT_ARGS 2
|
||||
|
||||
static void printCPUCacheNormal(const FFCPUCacheResult* result, FFCPUCacheOptions* options)
|
||||
{
|
||||
@@ -22,7 +21,7 @@ static void printCPUCacheNormal(const FFCPUCacheResult* result, FFCPUCacheOption
|
||||
else
|
||||
{
|
||||
uint32_t index = i + 1;
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 3, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(index, "index"),
|
||||
FF_FORMAT_ARG(levelStr, "level"),
|
||||
FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"),
|
||||
@@ -61,7 +60,7 @@ static void printCPUCacheNormal(const FFCPUCacheResult* result, FFCPUCacheOption
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY buffer2 = ffStrbufCreate();
|
||||
ffParseSize(sum, &buffer2);
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_CPUCACHE_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(buffer, "result"),
|
||||
FF_FORMAT_ARG(buffer2, "sum"),
|
||||
}));
|
||||
@@ -94,7 +93,7 @@ static void printCPUCacheCompact(const FFCPUCacheResult* result, FFCPUCacheOptio
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY buffer2 = ffStrbufCreate();
|
||||
ffParseSize(sum, &buffer2);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CPUCACHE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CPUCACHE_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CPUCACHE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(buffer, "result"),
|
||||
FF_FORMAT_ARG(buffer2, "sum"),
|
||||
}));
|
||||
@@ -228,27 +227,23 @@ exit:
|
||||
ffListDestroy(&result.caches[3]);
|
||||
}
|
||||
|
||||
void ffPrintCPUCacheHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CPUCACHE_DISPLAY_NAME, "{1}", FF_CPUCACHE_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Separate result - result",
|
||||
"Sum result - sum",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_CPUCACHE_MODULE_NAME,
|
||||
.description = "Print CPU cache sizes",
|
||||
.parseCommandOptions = (void*) ffParseCPUCacheCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseCPUCacheJsonObject,
|
||||
.printModule = (void*) ffPrintCPUCache,
|
||||
.generateJsonResult = (void*) ffGenerateCPUCacheJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateCPUCacheJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Separate result", "result"},
|
||||
{"Sum result", "sum"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitCPUCacheOptions(FFCPUCacheOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_CPUCACHE_MODULE_NAME,
|
||||
"Print CPU cache sizes",
|
||||
ffParseCPUCacheCommandOptions,
|
||||
ffParseCPUCacheJsonObject,
|
||||
ffPrintCPUCache,
|
||||
ffGenerateCPUCacheJsonResult,
|
||||
ffPrintCPUCacheHelpFormat,
|
||||
ffGenerateCPUCacheJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->compact = false;
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_CPUUSAGE_DISPLAY_NAME "CPU Usage"
|
||||
#define FF_CPUUSAGE_NUM_FORMAT_ARGS 8
|
||||
|
||||
void ffPrintCPUUsage(FFCPUUsageOptions* options)
|
||||
{
|
||||
@@ -94,7 +93,7 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
|
||||
if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
ffPercentAppendBar(&maxBar, maxValue, options->percent, &options->moduleArgs);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CPUUSAGE_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(avgNum, "avg"),
|
||||
FF_FORMAT_ARG(maxNum, "max"),
|
||||
FF_FORMAT_ARG(maxIndex, "max-index"),
|
||||
@@ -194,33 +193,29 @@ void ffGenerateCPUUsageJsonResult(FFCPUUsageOptions* options, yyjson_mut_doc* do
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintCPUUsageHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CPUUSAGE_MODULE_NAME, "{1}", FF_CPUUSAGE_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"CPU usage (percentage num, average) - avg",
|
||||
"CPU usage (percentage num, maximum) - max",
|
||||
"CPU core index of maximum usage - max-index",
|
||||
"CPU usage (percentage num, minimum) - min",
|
||||
"CPU core index of minimum usage - min-index",
|
||||
"CPU usage (percentage bar, average) - avg-bar",
|
||||
"CPU usage (percentage bar, maximum) - max-bar",
|
||||
"CPU usage (percentage bar, minimum) - min-bar",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_CPUUSAGE_MODULE_NAME,
|
||||
.description = "Print CPU usage. Costs some time to collect data",
|
||||
.parseCommandOptions = (void*) ffParseCPUUsageCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseCPUUsageJsonObject,
|
||||
.printModule = (void*) ffPrintCPUUsage,
|
||||
.generateJsonResult = (void*) ffGenerateCPUUsageJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateCPUUsageJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"CPU usage (percentage num, average)", "avg"},
|
||||
{"CPU usage (percentage num, maximum)", "max"},
|
||||
{"CPU core index of maximum usage", "max-index"},
|
||||
{"CPU usage (percentage num, minimum)", "min"},
|
||||
{"CPU core index of minimum usage", "min-index"},
|
||||
{"CPU usage (percentage bar, average)", "avg-bar"},
|
||||
{"CPU usage (percentage bar, maximum)", "max-bar"},
|
||||
{"CPU usage (percentage bar, minimum)", "min-bar"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitCPUUsageOptions(FFCPUUsageOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_CPUUSAGE_MODULE_NAME,
|
||||
"Print CPU usage. Costs some time to collect data",
|
||||
ffParseCPUUsageCommandOptions,
|
||||
ffParseCPUUsageJsonObject,
|
||||
ffPrintCPUUsage,
|
||||
ffGenerateCPUUsageJsonResult,
|
||||
ffPrintCPUUsageHelpFormat,
|
||||
ffGenerateCPUUsageJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
options->separate = false;
|
||||
options->percent = (FFPercentageModuleConfig) { 50, 80, 0 };
|
||||
|
||||
+15
-21
@@ -4,8 +4,6 @@
|
||||
#include "modules/cursor/cursor.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_CURSOR_NUM_FORMAT_ARGS 2
|
||||
|
||||
void ffPrintCursor(FFCursorOptions* options)
|
||||
{
|
||||
FFCursorResult result;
|
||||
@@ -38,7 +36,7 @@ void ffPrintCursor(FFCursorOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CURSOR_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result.theme, "theme"),
|
||||
FF_FORMAT_ARG(result.size, "size"),
|
||||
}));
|
||||
@@ -110,27 +108,23 @@ void ffGenerateCursorJsonResult(FF_MAYBE_UNUSED FFCursorOptions* options, yyjson
|
||||
ffStrbufDestroy(&result.size);
|
||||
}
|
||||
|
||||
void ffPrintCursorHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CURSOR_MODULE_NAME, "{1} ({2}px)", FF_CURSOR_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Cursor theme - theme",
|
||||
"Cursor size - size"
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_CURSOR_MODULE_NAME,
|
||||
.description = "Print cursor style name",
|
||||
.parseCommandOptions = (void*) ffParseCursorCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseCursorJsonObject,
|
||||
.printModule = (void*) ffPrintCursor,
|
||||
.generateJsonResult = (void*) ffGenerateCursorJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateCursorJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Cursor theme", "theme"},
|
||||
{"Cursor size", "size"},
|
||||
})),
|
||||
};
|
||||
|
||||
void ffInitCursorOptions(FFCursorOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_CURSOR_MODULE_NAME,
|
||||
"Print cursor style name",
|
||||
ffParseCursorCommandOptions,
|
||||
ffParseCursorJsonObject,
|
||||
ffPrintCursor,
|
||||
ffGenerateCursorJsonResult,
|
||||
ffPrintCursorHelpFormat,
|
||||
ffGenerateCursorJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+10
-11
@@ -44,19 +44,18 @@ void ffParseCustomJsonObject(FFCustomOptions* options, yyjson_val* module)
|
||||
}
|
||||
}
|
||||
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_CUSTOM_MODULE_NAME,
|
||||
.description = "Print a custom string, with or without key",
|
||||
.parseCommandOptions = (void*) ffParseCustomCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseCustomJsonObject,
|
||||
.printModule = (void*) ffPrintCustom,
|
||||
.generateJsonConfig = (void*) ffGenerateCustomJsonConfig,
|
||||
};
|
||||
|
||||
void ffInitCustomOptions(FFCustomOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_CUSTOM_MODULE_NAME,
|
||||
"Print a custom string, with or without key",
|
||||
ffParseCustomCommandOptions,
|
||||
ffParseCustomJsonObject,
|
||||
ffPrintCustom,
|
||||
NULL,
|
||||
NULL,
|
||||
ffGenerateCustomJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
ffStrbufSetStatic(&options->moduleArgs.key, " ");
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#pragma GCC diagnostic ignored "-Wformat" // warning: unknown conversion type character 'F' in format
|
||||
|
||||
#define FF_DATETIME_DISPLAY_NAME "Date & Time"
|
||||
#define FF_DATETIME_NUM_FORMAT_ARGS 23
|
||||
|
||||
typedef struct FFDateTimeResult
|
||||
{
|
||||
@@ -67,7 +66,7 @@ void ffPrintDateTimeFormat(struct tm* tm, const FFModuleArgs* moduleArgs)
|
||||
strftime(result.offsetFromUtc, sizeof(result.offsetFromUtc), "%z", tm);
|
||||
strftime(result.timezoneName, sizeof(result.timezoneName), "%Z", tm);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(FF_DATETIME_DISPLAY_NAME, 0, moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_DATETIME_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_DATETIME_DISPLAY_NAME, 0, moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result.year, "year"), // 1
|
||||
FF_FORMAT_ARG(result.yearShort, "year-short"), // 2
|
||||
FF_FORMAT_ARG(result.month, "month"), // 3
|
||||
@@ -158,48 +157,44 @@ void ffGenerateDateTimeJsonResult(FF_MAYBE_UNUSED FFDateTimeOptions* options, yy
|
||||
yyjson_mut_obj_add_strcpy(doc, module, "result", ffTimeToFullStr(ffTimeGetNow()));
|
||||
}
|
||||
|
||||
void ffPrintDateTimeHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DATETIME_MODULE_NAME, "{1}-{4}-{23} {14}:{18}:{20}", FF_DATETIME_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"year - year",
|
||||
"last two digits of year - year-short",
|
||||
"month - month",
|
||||
"month with leading zero - month-pretty",
|
||||
"month name - month-name",
|
||||
"month name short - month-name-short",
|
||||
"week number on year - week",
|
||||
"weekday - weekday",
|
||||
"weekday short - weekday-short",
|
||||
"day in year - day-in-year",
|
||||
"day in month - day-in-month",
|
||||
"day in week - day-in-week",
|
||||
"hour - hour",
|
||||
"hour with leading zero - hour-pretty",
|
||||
"hour 12h format - hour-12",
|
||||
"hour 12h format with leading zero - hour-12-pretty",
|
||||
"minute - minute",
|
||||
"minute with leading zero - minute-pretty",
|
||||
"second - second",
|
||||
"second with leading zero - second-pretty",
|
||||
"offset from UTC in the ISO 8601 format - offset-from-utc",
|
||||
"locale-dependent timezone name or abbreviation - timezone-name",
|
||||
"day in month with leading zero - day-pretty",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_DATETIME_MODULE_NAME,
|
||||
.description = "Print current date and time",
|
||||
.parseCommandOptions = (void*) ffParseDateTimeCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseDateTimeJsonObject,
|
||||
.printModule = (void*) ffPrintDateTime,
|
||||
.generateJsonResult = (void*) ffGenerateDateTimeJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateDateTimeJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Year", "year"},
|
||||
{"Last two digits of year", "year-short"},
|
||||
{"Month", "month"},
|
||||
{"Month with leading zero", "month-pretty"},
|
||||
{"Month name", "month-name"},
|
||||
{"Month name short", "month-name-short"},
|
||||
{"Week number on year", "week"},
|
||||
{"Weekday", "weekday"},
|
||||
{"Weekday short", "weekday-short"},
|
||||
{"Day in year", "day-in-year"},
|
||||
{"Day in month", "day-in-month"},
|
||||
{"Day in week", "day-in-week"},
|
||||
{"Hour", "hour"},
|
||||
{"Hour with leading zero", "hour-pretty"},
|
||||
{"Hour 12h format", "hour-12"},
|
||||
{"Hour 12h format with leading zero", "hour-12-pretty"},
|
||||
{"Minute", "minute"},
|
||||
{"Minute with leading zero", "minute-pretty"},
|
||||
{"Second", "second"},
|
||||
{"Second with leading zero", "second-pretty"},
|
||||
{"Offset from UTC in the ISO 8601 format", "offset-from-utc"},
|
||||
{"Locale-dependent timezone name or abbreviation", "timezone-name"},
|
||||
{"Day in month with leading zero", "day-pretty"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitDateTimeOptions(FFDateTimeOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_DATETIME_MODULE_NAME,
|
||||
"Print current date and time",
|
||||
ffParseDateTimeCommandOptions,
|
||||
ffParseDateTimeJsonObject,
|
||||
ffPrintDateTime,
|
||||
ffGenerateDateTimeJsonResult,
|
||||
ffPrintDateTimeHelpFormat,
|
||||
ffGenerateDateTimeJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+16
-22
@@ -5,8 +5,6 @@
|
||||
#include "modules/de/de.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_DE_NUM_FORMAT_ARGS 3
|
||||
|
||||
void ffPrintDE(FFDEOptions* options)
|
||||
{
|
||||
const FFDisplayServerResult* result = ffConnectDisplayServer();
|
||||
@@ -36,7 +34,7 @@ void ffPrintDE(FFDEOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_DE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_DE_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_DE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(result->deProcessName, "process-name"),
|
||||
FF_FORMAT_ARG(result->dePrettyName, "pretty-name"),
|
||||
FF_FORMAT_ARG(version, "version")
|
||||
@@ -113,28 +111,24 @@ void ffGenerateDEJsonResult(FF_MAYBE_UNUSED FFDEOptions* options, yyjson_mut_doc
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "version", &version);
|
||||
}
|
||||
|
||||
void ffPrintDEHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DE_MODULE_NAME, "{2} {3}", FF_DE_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"DE process name - process-name",
|
||||
"DE pretty name - pretty-name",
|
||||
"DE version - version"
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_DE_MODULE_NAME,
|
||||
.description = "Print desktop environment name",
|
||||
.parseCommandOptions = (void*) ffParseDECommandOptions,
|
||||
.parseJsonObject = (void*) ffParseDEJsonObject,
|
||||
.printModule = (void*) ffPrintDE,
|
||||
.generateJsonResult = (void*) ffGenerateDEJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateDEJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"DE process name", "process-name"},
|
||||
{"DE pretty name", "pretty-name"},
|
||||
{"DE version", "version"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitDEOptions(FFDEOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_DE_MODULE_NAME,
|
||||
"Print desktop environment name",
|
||||
ffParseDECommandOptions,
|
||||
ffParseDEJsonObject,
|
||||
ffPrintDE,
|
||||
ffGenerateDEJsonResult,
|
||||
ffPrintDEHelpFormat,
|
||||
ffGenerateDEJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->slowVersionDetection = false;
|
||||
|
||||
+29
-33
@@ -7,7 +7,6 @@
|
||||
#include "modules/disk/disk.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_DISK_NUM_FORMAT_ARGS 14
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
|
||||
static void printDisk(FFDiskOptions* options, const FFDisk* disk, uint32_t index)
|
||||
@@ -35,7 +34,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk, uint32_t index
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 5, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(disk->mountpoint, "mountpoint"),
|
||||
FF_FORMAT_ARG(disk->name, "name"),
|
||||
FF_FORMAT_ARG(disk->mountFrom, "mount-from"),
|
||||
@@ -126,7 +125,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk, uint32_t index
|
||||
bool isHidden = !!(disk->type & FF_DISK_VOLUME_TYPE_HIDDEN_BIT);
|
||||
bool isReadOnly = !!(disk->type & FF_DISK_VOLUME_TYPE_READONLY_BIT);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISK_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(usedPretty, "size-used"),
|
||||
FF_FORMAT_ARG(totalPretty, "size-total"),
|
||||
FF_FORMAT_ARG(bytesPercentageNum, "size-percentage"),
|
||||
@@ -440,39 +439,36 @@ void ffGenerateDiskJsonResult(FFDiskOptions* options, yyjson_mut_doc* doc, yyjso
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintDiskHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DISK_MODULE_NAME, "{1} / {2} ({3}) - {9}", FF_DISK_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Size used - size-used",
|
||||
"Size total - size-total",
|
||||
"Size percentage num - size-percentage",
|
||||
"Files used - files-used",
|
||||
"Files total - files-total",
|
||||
"Files percentage num - files-percentage",
|
||||
"True if external volume - is-external",
|
||||
"True if hidden volume - is-hidden",
|
||||
"Filesystem - filesystem",
|
||||
"Label / name - name",
|
||||
"True if read-only - is-readonly",
|
||||
"Create time in local timezone - create-time",
|
||||
"Size percentage bar - size-percentage-bar",
|
||||
"Files percentage bar - files-percentage-bar",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_DISK_MODULE_NAME,
|
||||
.description = "Print partitions, space usage, file system, etc",
|
||||
.parseCommandOptions = (void*) ffParseDiskCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseDiskJsonObject,
|
||||
.printModule = (void*) ffPrintDisk,
|
||||
.generateJsonResult = (void*) ffGenerateDiskJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateDiskJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Size used", "size-used"},
|
||||
{"Size total", "size-total"},
|
||||
{"Size percentage num", "size-percentage"},
|
||||
{"Files used", "files-used"},
|
||||
{"Files total", "files-total"},
|
||||
{"Files percentage num", "files-percentage"},
|
||||
{"True if external volume", "is-external"},
|
||||
{"True if hidden volume", "is-hidden"},
|
||||
{"Filesystem", "filesystem"},
|
||||
{"Label / name", "name"},
|
||||
{"True if read-only", "is-readonly"},
|
||||
{"Create time in local timezone", "create-time"},
|
||||
{"Size percentage bar", "size-percentage-bar"},
|
||||
{"Files percentage bar", "files-percentage-bar"},
|
||||
{},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitDiskOptions(FFDiskOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_DISK_MODULE_NAME,
|
||||
"Print partitions, space usage, file system, etc",
|
||||
ffParseDiskCommandOptions,
|
||||
ffParseDiskJsonObject,
|
||||
ffPrintDisk,
|
||||
ffGenerateDiskJsonResult,
|
||||
ffPrintDiskHelpFormat,
|
||||
ffGenerateDiskJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
ffStrbufInit(&options->folders);
|
||||
|
||||
+22
-27
@@ -6,7 +6,6 @@
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_DISKIO_DISPLAY_NAME "Disk IO"
|
||||
#define FF_DISKIO_NUM_FORMAT_ARGS 8
|
||||
|
||||
static int sortDevices(const FFDiskIOResult* left, const FFDiskIOResult* right)
|
||||
{
|
||||
@@ -22,7 +21,7 @@ static void formatKey(const FFDiskIOOptions* options, FFDiskIOResult* dev, uint3
|
||||
else
|
||||
{
|
||||
ffStrbufClear(key);
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, 4, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(index, "index"),
|
||||
FF_FORMAT_ARG(dev->name, "name"),
|
||||
FF_FORMAT_ARG(dev->devPath, "dev-path"),
|
||||
@@ -75,7 +74,7 @@ void ffPrintDiskIO(FFDiskIOOptions* options)
|
||||
ffParseSize(dev->bytesWritten, &buffer2);
|
||||
if (!options->detectTotal) ffStrbufAppendS(&buffer, "/s");
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISKIO_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(buffer, "size-read"),
|
||||
FF_FORMAT_ARG(buffer2, "size-written"),
|
||||
FF_FORMAT_ARG(dev->name, "name"),
|
||||
@@ -203,33 +202,29 @@ void ffGenerateDiskIOJsonResult(FFDiskIOOptions* options, yyjson_mut_doc* doc, y
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintDiskIOHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DISKIO_MODULE_NAME, "{1} (R) - {2} (W)", FF_DISKIO_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Size of data read [per second] (formatted) - size-read",
|
||||
"Size of data written [per second] (formatted) - size-written",
|
||||
"Device name - name",
|
||||
"Device raw file path - dev-path",
|
||||
"Size of data read [per second] (in bytes) - bytes-read",
|
||||
"Size of data written [per second] (in bytes) - bytes-written",
|
||||
"Number of reads - read-count",
|
||||
"Number of writes - write-count",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_DISKIO_MODULE_NAME,
|
||||
.description = "Print physical disk I/O throughput",
|
||||
.parseCommandOptions = (void*) ffParseDiskIOCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseDiskIOJsonObject,
|
||||
.printModule = (void*) ffPrintDiskIO,
|
||||
.generateJsonResult = (void*) ffGenerateDiskIOJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateDiskIOJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Size of data read [per second] (formatted)", "size-read"},
|
||||
{"Size of data written [per second] (formatted)", "size-written"},
|
||||
{"Device name", "name"},
|
||||
{"Device raw file path", "dev-path"},
|
||||
{"Size of data read [per second] (in bytes)", "bytes-read"},
|
||||
{"Size of data written [per second] (in bytes)", "bytes-written"},
|
||||
{"Number of reads", "read-count"},
|
||||
{"Number of writes", "write-count"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitDiskIOOptions(FFDiskIOOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_DISKIO_MODULE_NAME,
|
||||
"Print physical disk I/O throughput",
|
||||
ffParseDiskIOCommandOptions,
|
||||
ffParseDiskIOJsonObject,
|
||||
ffPrintDiskIO,
|
||||
ffGenerateDiskIOJsonResult,
|
||||
ffPrintDiskIOHelpFormat,
|
||||
ffGenerateDiskIOJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
ffStrbufInit(&options->namePrefix);
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#define FF_DISPLAY_NUM_FORMAT_ARGS 24
|
||||
|
||||
static int sortByNameAsc(FFDisplayResult* a, FFDisplayResult* b)
|
||||
{
|
||||
return ffStrbufComp(&a->name, &b->name);
|
||||
@@ -91,7 +89,7 @@ void ffPrintDisplay(FFDisplayOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 4, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(moduleIndex, "index"),
|
||||
FF_FORMAT_ARG(result->name, "name"),
|
||||
FF_FORMAT_ARG(displayType, "type"),
|
||||
@@ -186,7 +184,7 @@ void ffPrintDisplay(FFDisplayOptions* options)
|
||||
|
||||
double scaleFactor = (double) result->width / (double) result->scaledWidth;
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISPLAY_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result->width, "width"),
|
||||
FF_FORMAT_ARG(result->height, "height"),
|
||||
FF_FORMAT_ARG(refreshRate, "refresh-rate"),
|
||||
@@ -435,49 +433,45 @@ void ffGenerateDisplayJsonResult(FF_MAYBE_UNUSED FFDisplayOptions* options, yyjs
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintDisplayHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DISPLAY_MODULE_NAME, "{1}x{2} @ {3}Hz (as {4}x{5}) [{7}]", FF_DISPLAY_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Screen configured width (in pixels) - width",
|
||||
"Screen configured height (in pixels) - height",
|
||||
"Screen configured refresh rate (in Hz) - refresh-rate",
|
||||
"Screen scaled width (in pixels) - scaled-width",
|
||||
"Screen scaled height (in pixels) - scaled-height",
|
||||
"Screen name - name",
|
||||
"Screen type (builtin, external or unknown) - type",
|
||||
"Screen rotation (in degrees) - rotation",
|
||||
"True if being the primary screen - is-primary",
|
||||
"Screen physical width (in millimeters) - physical-width",
|
||||
"Screen physical height (in millimeters) - physical-height",
|
||||
"Physical diagonal length in inches - inch",
|
||||
"Pixels per inch (PPI) - ppi",
|
||||
"Bits per color channel - bit-depth",
|
||||
"True if high dynamic range (HDR) mode is enabled - hdr-enabled",
|
||||
"Year of manufacturing - manufacture-year",
|
||||
"Nth week of manufacturing in the year - manufacture-week",
|
||||
"Serial number - serial",
|
||||
"The platform API used when detecting the display - platform-api",
|
||||
"True if the display is HDR compatible - hdr-compatible",
|
||||
"HiDPI scale factor - scale-factor",
|
||||
"Screen preferred width (in pixels) - preferred-width",
|
||||
"Screen preferred height (in pixels) - preferred-height",
|
||||
"Screen preferred refresh rate (in Hz) - preferred-refresh-rate",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_DISPLAY_MODULE_NAME,
|
||||
.description = "Print resolutions, refresh rates, etc",
|
||||
.parseCommandOptions = (void*) ffParseDisplayCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseDisplayJsonObject,
|
||||
.printModule = (void*) ffPrintDisplay,
|
||||
.generateJsonResult = (void*) ffGenerateDisplayJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateDisplayJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Screen configured width (in pixels)", "width"},
|
||||
{"Screen configured height (in pixels)", "height"},
|
||||
{"Screen configured refresh rate (in Hz)", "refresh-rate"},
|
||||
{"Screen scaled width (in pixels)", "scaled-width"},
|
||||
{"Screen scaled height (in pixels)", "scaled-height"},
|
||||
{"Screen name", "name"},
|
||||
{"Screen type (builtin, external or unknown)", "type"},
|
||||
{"Screen rotation (in degrees)", "rotation"},
|
||||
{"True if being the primary screen", "is-primary"},
|
||||
{"Screen physical width (in millimeters)", "physical-width"},
|
||||
{"Screen physical height (in millimeters)", "physical-height"},
|
||||
{"Physical diagonal length in inches", "inch"},
|
||||
{"Pixels per inch (PPI)", "ppi"},
|
||||
{"Bits per color channel", "bit-depth"},
|
||||
{"True if high dynamic range (HDR) mode is enabled", "hdr-enabled"},
|
||||
{"Year of manufacturing", "manufacture-year"},
|
||||
{"Nth week of manufacturing in the year", "manufacture-week"},
|
||||
{"Serial number", "serial"},
|
||||
{"The platform API used when detecting the display", "platform-api"},
|
||||
{"True if the display is HDR compatible", "hdr-compatible"},
|
||||
{"HiDPI scale factor", "scale-factor"},
|
||||
{"Screen preferred width (in pixels)", "preferred-width"},
|
||||
{"Screen preferred height (in pixels)", "preferred-height"},
|
||||
{"Screen preferred refresh rate (in Hz)", "preferred-refresh-rate"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitDisplayOptions(FFDisplayOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_DISPLAY_MODULE_NAME,
|
||||
"Print resolutions, refresh rates, etc",
|
||||
ffParseDisplayCommandOptions,
|
||||
ffParseDisplayJsonObject,
|
||||
ffPrintDisplay,
|
||||
ffGenerateDisplayJsonResult,
|
||||
ffPrintDisplayHelpFormat,
|
||||
ffGenerateDisplayJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
options->compactType = FF_DISPLAY_COMPACT_TYPE_NONE;
|
||||
options->preciseRefreshRate = false;
|
||||
|
||||
+14
-20
@@ -4,8 +4,6 @@
|
||||
#include "modules/dns/dns.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_DNS_NUM_FORMAT_ARGS 1
|
||||
|
||||
void ffPrintDNS(FFDNSOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFstrbuf));
|
||||
@@ -48,7 +46,7 @@ void ffPrintDNS(FFDNSOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_DNS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_DNS_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_DNS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(buf, "result"),
|
||||
}));
|
||||
}
|
||||
@@ -166,26 +164,22 @@ exit:
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintDNSHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DNS_MODULE_NAME, "{1}", FF_DNS_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"DNS result - result",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_DNS_MODULE_NAME,
|
||||
.description = "Print configured DNS servers",
|
||||
.parseCommandOptions = (void*) ffParseDNSCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseDNSJsonObject,
|
||||
.printModule = (void*) ffPrintDNS,
|
||||
.generateJsonResult = (void*) ffGenerateDNSJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateDNSJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"DNS result", "result"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitDNSOptions(FFDNSOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_DNS_MODULE_NAME,
|
||||
"Print configured DNS servers",
|
||||
ffParseDNSCommandOptions,
|
||||
ffParseDNSJsonObject,
|
||||
ffPrintDNS,
|
||||
ffGenerateDNSJsonResult,
|
||||
ffPrintDNSHelpFormat,
|
||||
ffGenerateDNSJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->showType = FF_DNS_TYPE_BOTH;
|
||||
|
||||
+18
-24
@@ -5,8 +5,6 @@
|
||||
#include "modules/editor/editor.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_EDITOR_NUM_FORMAT_ARGS 5
|
||||
|
||||
void ffPrintEditor(FFEditorOptions* options)
|
||||
{
|
||||
FFEditorResult result = {
|
||||
@@ -41,7 +39,7 @@ void ffPrintEditor(FFEditorOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_EDITOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_EDITOR_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_EDITOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(result.type, "type"),
|
||||
FF_FORMAT_ARG(result.name, "name"),
|
||||
FF_FORMAT_ARG(result.exe, "exe-name"),
|
||||
@@ -120,30 +118,26 @@ void ffGenerateEditorJsonResult(FF_MAYBE_UNUSED FFEditorOptions* options, yyjson
|
||||
ffStrbufDestroy(&result.version);
|
||||
}
|
||||
|
||||
void ffPrintEditorHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_EDITOR_MODULE_NAME, "{2} ({4})", FF_EDITOR_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Type (Visual / Editor) - type",
|
||||
"Name - name",
|
||||
"Exe name of real path - exe-name",
|
||||
"Full path of real path - full-path",
|
||||
"Version - version",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_EDITOR_MODULE_NAME,
|
||||
.description = "Print information of the default editor ($VISUAL or $EDITOR)",
|
||||
.parseCommandOptions = (void*) ffParseEditorCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseEditorJsonObject,
|
||||
.printModule = (void*) ffPrintEditor,
|
||||
.generateJsonResult = (void*) ffGenerateEditorJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateEditorJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Type (Visual / Editor)", "type"},
|
||||
{"Name", "name"},
|
||||
{"Exe name of real path", "exe-name"},
|
||||
{"Full path of real path", "full-path"},
|
||||
{"Version", "version"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitEditorOptions(FFEditorOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_EDITOR_MODULE_NAME,
|
||||
"Print information of the default editor ($VISUAL or $EDITOR)",
|
||||
ffParseEditorCommandOptions,
|
||||
ffParseEditorJsonObject,
|
||||
ffPrintEditor,
|
||||
ffGenerateEditorJsonResult,
|
||||
ffPrintEditorHelpFormat,
|
||||
ffGenerateEditorJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+18
-24
@@ -4,8 +4,6 @@
|
||||
#include "modules/font/font.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_FONT_NUM_FORMAT_ARGS (FF_DETECT_FONT_NUM_FONTS + 1)
|
||||
|
||||
void ffPrintFont(FFFontOptions* options)
|
||||
{
|
||||
FFFontResult font;
|
||||
@@ -28,7 +26,7 @@ void ffPrintFont(FFFontOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_FONT_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_FONT_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_FONT_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(font.fonts[0], "font1"),
|
||||
FF_FORMAT_ARG(font.fonts[1], "font2"),
|
||||
FF_FORMAT_ARG(font.fonts[2], "font3"),
|
||||
@@ -104,30 +102,26 @@ void ffGenerateFontJsonResult(FF_MAYBE_UNUSED FFFontOptions* options, yyjson_mut
|
||||
ffStrbufDestroy(&font.fonts[i]);
|
||||
}
|
||||
|
||||
void ffPrintFontHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_FONT_MODULE_NAME, "{5}", FF_FONT_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Font 1 - font1",
|
||||
"Font 2 - font2",
|
||||
"Font 3 - font3",
|
||||
"Font 4 - font4",
|
||||
"Combined fonts for display - combined"
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_FONT_MODULE_NAME,
|
||||
.description = "Print system font names",
|
||||
.parseCommandOptions = (void*) ffParseFontCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseFontJsonObject,
|
||||
.printModule = (void*) ffPrintFont,
|
||||
.generateJsonResult = (void*) ffGenerateFontJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateFontJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Font 1", "font1"},
|
||||
{"Font 2", "font2"},
|
||||
{"Font 3", "font3"},
|
||||
{"Font 4", "font4"},
|
||||
{"Combined fonts for display", "combined"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitFontOptions(FFFontOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_FONT_MODULE_NAME,
|
||||
"Print system font name",
|
||||
ffParseFontCommandOptions,
|
||||
ffParseFontJsonObject,
|
||||
ffPrintFont,
|
||||
ffGenerateFontJsonResult,
|
||||
ffPrintFontHelpFormat,
|
||||
ffGenerateFontJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
#include "modules/gamepad/gamepad.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_GAMEPAD_NUM_FORMAT_ARGS 4
|
||||
|
||||
static void printDevice(FFGamepadOptions* options, const FFGamepadDevice* device, uint8_t index)
|
||||
{
|
||||
FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type;
|
||||
@@ -43,7 +41,7 @@ static void printDevice(FFGamepadOptions* options, const FFGamepadDevice* device
|
||||
if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
ffPercentAppendBar(&percentageBar, device->battery, options->percent, &options->moduleArgs);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_GAMEPAD_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(device->name, "name"),
|
||||
FF_FORMAT_ARG(device->serial, "serial"),
|
||||
FF_FORMAT_ARG(percentageNum, "battery-percentage"),
|
||||
@@ -149,29 +147,25 @@ void ffGenerateGamepadJsonResult(FF_MAYBE_UNUSED FFGamepadOptions* options, yyjs
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintGamepadHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_GAMEPAD_MODULE_NAME, "{1} ({3})", FF_GAMEPAD_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Name - name",
|
||||
"Serial number - serial",
|
||||
"Battery percentage num - battery-percentage",
|
||||
"Battery percentage bar - battery-percentage-bar",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_GAMEPAD_MODULE_NAME,
|
||||
.description = "List (connected) gamepads",
|
||||
.parseCommandOptions = (void*) ffParseGamepadCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseGamepadJsonObject,
|
||||
.printModule = (void*) ffPrintGamepad,
|
||||
.generateJsonResult = (void*) ffGenerateGamepadJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateGamepadJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Name", "name"},
|
||||
{"Serial number", "serial"},
|
||||
{"Battery percentage num", "battery-percentage"},
|
||||
{"Battery percentage bar", "battery-percentage-bar"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitGamepadOptions(FFGamepadOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_GAMEPAD_MODULE_NAME,
|
||||
"List connected gamepads",
|
||||
ffParseGamepadCommandOptions,
|
||||
ffParseGamepadJsonObject,
|
||||
ffPrintGamepad,
|
||||
ffGenerateGamepadJsonResult,
|
||||
ffPrintGamepadHelpFormat,
|
||||
ffGenerateGamepadJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
options->percent = (FFPercentageModuleConfig) { 50, 20, 0 };
|
||||
}
|
||||
|
||||
+26
-32
@@ -10,8 +10,6 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FF_GPU_NUM_FORMAT_ARGS 13
|
||||
|
||||
static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResult* gpu)
|
||||
{
|
||||
const char* type;
|
||||
@@ -90,7 +88,7 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
|
||||
FF_STRBUF_AUTO_DESTROY frequency = ffStrbufCreate();
|
||||
ffParseFrequency(gpu->frequency, &frequency);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(FF_GPU_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_GPU_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_GPU_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(gpu->vendor, "vendor"),
|
||||
FF_FORMAT_ARG(gpu->name, "name"),
|
||||
FF_FORMAT_ARG(gpu->driver, "driver"),
|
||||
@@ -394,38 +392,34 @@ void ffGenerateGPUJsonResult(FFGPUOptions* options, yyjson_mut_doc* doc, yyjson_
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintGPUHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_GPU_MODULE_NAME, "{1} {2}", FF_GPU_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"GPU vendor - vendor",
|
||||
"GPU name - name",
|
||||
"GPU driver - driver",
|
||||
"GPU temperature - temperature",
|
||||
"GPU core count - core-count",
|
||||
"GPU type - type",
|
||||
"GPU total dedicated memory - dedicated-total",
|
||||
"GPU used dedicated memory - dedicated-used",
|
||||
"GPU total shared memory - shared-total",
|
||||
"GPU used shared memory - shared-used",
|
||||
"The platform API used when detecting the GPU - platform-api",
|
||||
"Current frequency in GHz - frequency",
|
||||
"GPU vendor specific index - index",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_GPU_MODULE_NAME,
|
||||
.description = "Print GPU names, graphic memory size, type, etc",
|
||||
.parseCommandOptions = (void*) ffParseGPUCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseGPUJsonObject,
|
||||
.printModule = (void*) ffPrintGPU,
|
||||
.generateJsonResult = (void*) ffGenerateGPUJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateGPUJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"GPU vendor", "vendor"},
|
||||
{"GPU name", "name"},
|
||||
{"GPU driver", "driver"},
|
||||
{"GPU temperature", "temperature"},
|
||||
{"GPU core count", "core-count"},
|
||||
{"GPU type", "type"},
|
||||
{"GPU total dedicated memory", "dedicated-total"},
|
||||
{"GPU used dedicated memory", "dedicated-used"},
|
||||
{"GPU total shared memory", "shared-total"},
|
||||
{"GPU used shared memory", "shared-used"},
|
||||
{"The platform API used when detecting the GPU", "platform-api"},
|
||||
{"Current frequency in GHz", "frequency"},
|
||||
{"GPU vendor specific index", "index"},
|
||||
})),
|
||||
};
|
||||
|
||||
void ffInitGPUOptions(FFGPUOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_GPU_MODULE_NAME,
|
||||
"Print GPU names, graphic memory size, type, etc",
|
||||
ffParseGPUCommandOptions,
|
||||
ffParseGPUJsonObject,
|
||||
ffPrintGPU,
|
||||
ffGenerateGPUJsonResult,
|
||||
ffPrintGPUHelpFormat,
|
||||
ffGenerateGPUJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->driverSpecific = false;
|
||||
|
||||
+20
-26
@@ -4,8 +4,6 @@
|
||||
#include "modules/host/host.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_HOST_NUM_FORMAT_ARGS 7
|
||||
|
||||
void ffPrintHost(FFHostOptions* options)
|
||||
{
|
||||
FFHostResult host;
|
||||
@@ -48,7 +46,7 @@ void ffPrintHost(FFHostOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_HOST_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_HOST_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_HOST_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(host.family, "family"),
|
||||
FF_FORMAT_ARG(host.name, "name"),
|
||||
FF_FORMAT_ARG(host.version, "version"),
|
||||
@@ -147,32 +145,28 @@ exit:
|
||||
ffStrbufDestroy(&host.vendor);
|
||||
}
|
||||
|
||||
void ffPrintHostHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_HOST_MODULE_NAME, "{2} {3}", FF_HOST_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"product family - family",
|
||||
"product name - name",
|
||||
"product version - version",
|
||||
"product sku - sku",
|
||||
"product vendor - vendor",
|
||||
"product serial number - serial",
|
||||
"product uuid - uuid",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_HOST_MODULE_NAME,
|
||||
.description = "Print product name of your computer",
|
||||
.parseCommandOptions = (void*) ffParseHostCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseHostJsonObject,
|
||||
.printModule = (void*) ffPrintHost,
|
||||
.generateJsonResult = (void*) ffGenerateHostJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateHostJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Product family", "family"},
|
||||
{"Product name", "name"},
|
||||
{"Product version", "version"},
|
||||
{"Product sku", "sku"},
|
||||
{"Product vendor", "vendor"},
|
||||
{"Product serial number", "serial"},
|
||||
{"Product uuid", "uuid"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitHostOptions(FFHostOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_HOST_MODULE_NAME,
|
||||
"Print product name of your computer",
|
||||
ffParseHostCommandOptions,
|
||||
ffParseHostJsonObject,
|
||||
ffPrintHost,
|
||||
ffGenerateHostJsonResult,
|
||||
ffPrintHostHelpFormat,
|
||||
ffGenerateHostJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+15
-21
@@ -4,8 +4,6 @@
|
||||
#include "modules/icons/icons.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_ICONS_NUM_FORMAT_ARGS 2
|
||||
|
||||
void ffPrintIcons(FFIconsOptions* options)
|
||||
{
|
||||
FFIconsResult result = {
|
||||
@@ -35,7 +33,7 @@ void ffPrintIcons(FFIconsOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_ICONS_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(result.icons1, "icons1"),
|
||||
FF_FORMAT_ARG(result.icons2, "icons2"),
|
||||
}));
|
||||
@@ -102,27 +100,23 @@ void ffGenerateIconsJsonResult(FF_MAYBE_UNUSED FFIconsOptions* options, yyjson_m
|
||||
ffStrbufDestroy(&result.icons2);
|
||||
}
|
||||
|
||||
void ffPrintIconsHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_ICONS_MODULE_NAME, "{1}, {2}", FF_ICONS_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Icons part 1 - icons1",
|
||||
"Icons part 2 - icons2",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_ICONS_MODULE_NAME,
|
||||
.description = "Print icon style name",
|
||||
.parseCommandOptions = (void*) ffParseIconsCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseIconsJsonObject,
|
||||
.printModule = (void*) ffPrintIcons,
|
||||
.generateJsonResult = (void*) ffGenerateIconsJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateIconsJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Icons part 1", "icons1"},
|
||||
{"Icons part 2", "icons2"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitIconsOptions(FFIconsOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_ICONS_MODULE_NAME,
|
||||
"Print icon style name",
|
||||
ffParseIconsCommandOptions,
|
||||
ffParseIconsJsonObject,
|
||||
ffPrintIcons,
|
||||
ffGenerateIconsJsonResult,
|
||||
ffPrintIconsHelpFormat,
|
||||
ffGenerateIconsJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "modules/initsystem/initsystem.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_INITSYSTEM_NUM_FORMAT_ARGS 4
|
||||
#define FF_INITSYSTEM_DISPLAY_NAME "Init System"
|
||||
|
||||
void ffPrintInitSystem(FFInitSystemOptions* options)
|
||||
@@ -35,7 +34,7 @@ void ffPrintInitSystem(FFInitSystemOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_INITSYSTEM_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_INITSYSTEM_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_INITSYSTEM_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result.name, "name"),
|
||||
FF_FORMAT_ARG(result.exe, "exe"),
|
||||
FF_FORMAT_ARG(result.version, "version"),
|
||||
@@ -113,29 +112,25 @@ exit:
|
||||
ffStrbufDestroy(&result.version);
|
||||
}
|
||||
|
||||
void ffPrintInitSystemHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_INITSYSTEM_DISPLAY_NAME, "{1}", FF_INITSYSTEM_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"init system name - name",
|
||||
"init system exe path - exe",
|
||||
"init system version path - version",
|
||||
"init system pid - pid",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_INITSYSTEM_MODULE_NAME,
|
||||
.description = "Print init system (pid 1) name and version",
|
||||
.parseCommandOptions = (void*) ffParseInitSystemCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseInitSystemJsonObject,
|
||||
.printModule = (void*) ffPrintInitSystem,
|
||||
.generateJsonResult = (void*) ffGenerateInitSystemJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateInitSystemJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Init system name", "name"},
|
||||
{"Init system exe path", "exe"},
|
||||
{"Init system version path", "version"},
|
||||
{"Init system pid", "pid"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitInitSystemOptions(FFInitSystemOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_INITSYSTEM_MODULE_NAME,
|
||||
"Print init system (pid 1) name and version",
|
||||
ffParseInitSystemCommandOptions,
|
||||
ffParseInitSystemJsonObject,
|
||||
ffPrintInitSystem,
|
||||
ffGenerateInitSystemJsonResult,
|
||||
ffPrintInitSystemHelpFormat,
|
||||
ffGenerateInitSystemJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+19
-25
@@ -3,8 +3,6 @@
|
||||
#include "modules/kernel/kernel.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_KERNEL_NUM_FORMAT_ARGS 6
|
||||
|
||||
void ffPrintKernel(FFKernelOptions* options)
|
||||
{
|
||||
const FFPlatformSysinfo* info = &instance.state.platform.sysinfo;
|
||||
@@ -22,7 +20,7 @@ void ffPrintKernel(FFKernelOptions* options)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
ffParseSize(info->pageSize, &str);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_KERNEL_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(info->name, "sysname"),
|
||||
FF_FORMAT_ARG(info->release, "release"),
|
||||
FF_FORMAT_ARG(info->version, "version"),
|
||||
@@ -81,31 +79,27 @@ void ffGenerateKernelJsonResult(FF_MAYBE_UNUSED FFKernelOptions* options, yyjson
|
||||
yyjson_mut_obj_add_uint(doc, obj, "pageSize", info->pageSize);
|
||||
}
|
||||
|
||||
void ffPrintKernelHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_KERNEL_MODULE_NAME, "{1} {2}", FF_KERNEL_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Sysname - sysname",
|
||||
"Release - release",
|
||||
"Version - version",
|
||||
"Architecture - arch",
|
||||
"Display version - display-version",
|
||||
"Page size - page-size",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_KERNEL_MODULE_NAME,
|
||||
.description = "Print system kernel version",
|
||||
.parseCommandOptions = (void*) ffParseKernelCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseKernelJsonObject,
|
||||
.printModule = (void*) ffPrintKernel,
|
||||
.generateJsonResult = (void*) ffGenerateKernelJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateKernelJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Sysname", "sysname"},
|
||||
{"Release", "release"},
|
||||
{"Version", "version"},
|
||||
{"Architecture", "arch"},
|
||||
{"Display version", "display-version"},
|
||||
{"Page size", "page-size"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitKernelOptions(FFKernelOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_KERNEL_MODULE_NAME,
|
||||
"Print system kernel version",
|
||||
ffParseKernelCommandOptions,
|
||||
ffParseKernelJsonObject,
|
||||
ffPrintKernel,
|
||||
ffGenerateKernelJsonResult,
|
||||
ffPrintKernelHelpFormat,
|
||||
ffGenerateKernelJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
#include "modules/keyboard/keyboard.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_KEYBOARD_NUM_FORMAT_ARGS 2
|
||||
|
||||
static void printDevice(FFKeyboardOptions* options, const FFKeyboardDevice* device, uint8_t index)
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
@@ -16,7 +14,7 @@ static void printDevice(FFKeyboardOptions* options, const FFKeyboardDevice* devi
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_KEYBOARD_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_KEYBOARD_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_KEYBOARD_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(device->name, "name"),
|
||||
FF_FORMAT_ARG(device->serial, "serial"),
|
||||
}));
|
||||
@@ -112,27 +110,23 @@ void ffGenerateKeyboardJsonResult(FF_MAYBE_UNUSED FFKeyboardOptions* options, yy
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintKeyboardHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_KEYBOARD_MODULE_NAME, "{1} ({3})", FF_KEYBOARD_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Name - name",
|
||||
"Serial number - serial",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_KEYBOARD_MODULE_NAME,
|
||||
.description = "List (connected) keyboards",
|
||||
.parseCommandOptions = (void*) ffParseKeyboardCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseKeyboardJsonObject,
|
||||
.printModule = (void*) ffPrintKeyboard,
|
||||
.generateJsonResult = (void*) ffGenerateKeyboardJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateKeyboardJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Name", "name"},
|
||||
{"Serial number", "serial"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitKeyboardOptions(FFKeyboardOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_KEYBOARD_MODULE_NAME,
|
||||
"List connected keyboards",
|
||||
ffParseKeyboardCommandOptions,
|
||||
ffParseKeyboardJsonObject,
|
||||
ffPrintKeyboard,
|
||||
ffGenerateKeyboardJsonResult,
|
||||
ffPrintKeyboardHelpFormat,
|
||||
ffGenerateKeyboardJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+16
-22
@@ -4,8 +4,6 @@
|
||||
#include "modules/lm/lm.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_LM_NUM_FORMAT_ARGS 3
|
||||
|
||||
void ffPrintLM(FFLMOptions* options)
|
||||
{
|
||||
FFLMResult result;
|
||||
@@ -38,7 +36,7 @@ void ffPrintLM(FFLMOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_LM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_LM_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_LM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(result.service, "service"),
|
||||
FF_FORMAT_ARG(result.type, "type"),
|
||||
FF_FORMAT_ARG(result.version, "version"),
|
||||
@@ -115,28 +113,24 @@ exit:
|
||||
ffStrbufDestroy(&result.version);
|
||||
}
|
||||
|
||||
void ffPrintLMHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_LM_MODULE_NAME, "{1} {3} ({2})", FF_LM_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"LM service - service",
|
||||
"LM type - type",
|
||||
"LM version - version"
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_LM_MODULE_NAME,
|
||||
.description = "Print login manager (desktop manager) name and version",
|
||||
.parseCommandOptions = (void*) ffParseLMCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseLMJsonObject,
|
||||
.printModule = (void*) ffPrintLM,
|
||||
.generateJsonResult = (void*) ffGenerateLMJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateLMJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"LM service", "service"},
|
||||
{"LM type", "type"},
|
||||
{"LM version", "version"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitLMOptions(FFLMOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_LM_MODULE_NAME,
|
||||
"Print login manager (desktop manager) name and version",
|
||||
ffParseLMCommandOptions,
|
||||
ffParseLMJsonObject,
|
||||
ffPrintLM,
|
||||
ffGenerateLMJsonResult,
|
||||
ffPrintLMHelpFormat,
|
||||
ffGenerateLMJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
#include "modules/loadavg/loadavg.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_LOADAVG_NUM_FORMAT_ARGS 3
|
||||
|
||||
void ffPrintLoadavg(FFLoadavgOptions* options)
|
||||
{
|
||||
double result[3] = { 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0 };
|
||||
@@ -48,7 +46,7 @@ void ffPrintLoadavg(FFLoadavgOptions* options)
|
||||
else
|
||||
{
|
||||
ffStrbufClear(&buffer);
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&buffer, &options->moduleArgs.key, 3, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&buffer, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(index, "index"),
|
||||
FF_FORMAT_ARG(duration, "duration"),
|
||||
FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"),
|
||||
@@ -84,7 +82,7 @@ void ffPrintLoadavg(FFLoadavgOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_LOADAVG_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_LOADAVG_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_LOADAVG_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(result[0], "loadavg1"),
|
||||
FF_FORMAT_ARG(result[1], "loadavg2"),
|
||||
FF_FORMAT_ARG(result[2], "loadavg3"),
|
||||
@@ -181,28 +179,24 @@ void ffGenerateLoadavgJsonResult(FF_MAYBE_UNUSED FFLoadavgOptions* options, yyjs
|
||||
yyjson_mut_arr_add_real(doc, arr, result[i]);
|
||||
}
|
||||
|
||||
void ffPrintLoadavgHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_LOADAVG_MODULE_NAME, "{1}, {2}, {3}", FF_LOADAVG_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Load average over 1min - loadavg1",
|
||||
"Load average over 5min - loadavg2",
|
||||
"Load average over 15min - loadavg3",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_LOADAVG_MODULE_NAME,
|
||||
.description = "Print system load averages",
|
||||
.parseCommandOptions = (void*) ffParseLoadavgCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseLoadavgJsonObject,
|
||||
.printModule = (void*) ffPrintLoadavg,
|
||||
.generateJsonResult = (void*) ffGenerateLoadavgJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateLoadavgJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Load average over 1min", "loadavg1"},
|
||||
{"Load average over 5min", "loadavg2"},
|
||||
{"Load average over 15min", "loadavg3"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitLoadavgOptions(FFLoadavgOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_LOADAVG_MODULE_NAME,
|
||||
"Print system load averages",
|
||||
ffParseLoadavgCommandOptions,
|
||||
ffParseLoadavgJsonObject,
|
||||
ffPrintLoadavg,
|
||||
ffGenerateLoadavgJsonResult,
|
||||
ffPrintLoadavgHelpFormat,
|
||||
ffGenerateLoadavgJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->percent = (FFPercentageModuleConfig) { 50, 80, 0 };
|
||||
|
||||
+14
-20
@@ -4,8 +4,6 @@
|
||||
#include "modules/locale/locale.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_LOCALE_NUM_FORMAT_ARGS 1
|
||||
|
||||
void ffPrintLocale(FFLocaleOptions* options)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY locale = ffStrbufCreate();
|
||||
@@ -24,7 +22,7 @@ void ffPrintLocale(FFLocaleOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_LOCALE_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(locale, "result")
|
||||
}));
|
||||
}
|
||||
@@ -79,26 +77,22 @@ void ffGenerateLocaleJsonResult(FF_MAYBE_UNUSED FFLocaleOptions* options, yyjson
|
||||
yyjson_mut_obj_add_strbuf(doc, module, "result", &locale);
|
||||
}
|
||||
|
||||
void ffPrintLocaleHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_LOCALE_MODULE_NAME, "{1}", FF_LOCALE_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Locale code - result"
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_LOCALE_MODULE_NAME,
|
||||
.description = "Print system locale name",
|
||||
.parseCommandOptions = (void*) ffParseLocaleCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseLocaleJsonObject,
|
||||
.printModule = (void*) ffPrintLocale,
|
||||
.generateJsonResult = (void*) ffGenerateLocaleJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateLocaleJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Locale code", "result"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitLocaleOptions(FFLocaleOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_LOCALE_MODULE_NAME,
|
||||
"Print system locale name",
|
||||
ffParseLocaleCommandOptions,
|
||||
ffParseLocaleJsonObject,
|
||||
ffPrintLocale,
|
||||
ffGenerateLocaleJsonResult,
|
||||
ffPrintLocaleHelpFormat,
|
||||
ffGenerateLocaleJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_LOCALIP_DISPLAY_NAME "Local IP"
|
||||
#define FF_LOCALIP_NUM_FORMAT_ARGS 8
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
|
||||
static int sortIps(const FFLocalIpResult* left, const FFLocalIpResult* right)
|
||||
@@ -25,7 +24,7 @@ static void formatKey(const FFLocalIpOptions* options, FFLocalIpResult* ip, uint
|
||||
else
|
||||
{
|
||||
ffStrbufClear(key);
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, 4, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(index, "index"),
|
||||
FF_FORMAT_ARG(ip->name, "name"),
|
||||
FF_FORMAT_ARG(ip->mac, "mac"),
|
||||
@@ -149,7 +148,7 @@ void ffPrintLocalIp(FFLocalIpOptions* options)
|
||||
else
|
||||
ffStrbufSetF(&speedStr, "%u Mbps", (unsigned) ip->speed);
|
||||
}
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_LOCALIP_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(ip->ipv4, "ipv4"),
|
||||
FF_FORMAT_ARG(ip->ipv6, "ipv6"),
|
||||
FF_FORMAT_ARG(ip->mac, "mac"),
|
||||
@@ -500,33 +499,29 @@ void ffGenerateLocalIpJsonResult(FF_MAYBE_UNUSED FFLocalIpOptions* options, yyjs
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintLocalIpHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_LOCALIP_MODULE_NAME, "{1}", FF_LOCALIP_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Local IPv4 address - ipv4",
|
||||
"Local IPv6 address - ipv6",
|
||||
"Physical (MAC) address - mac",
|
||||
"Interface name - ifname",
|
||||
"Is default route - is-default-route",
|
||||
"MTU size in bytes - mtu",
|
||||
"Link speed (formatted) - speed",
|
||||
"Interface flags - flags",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_LOCALIP_MODULE_NAME,
|
||||
.description = "List local IP addresses (v4 or v6), MAC addresses, etc",
|
||||
.parseCommandOptions = (void*) ffParseLocalIpCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseLocalIpJsonObject,
|
||||
.printModule = (void*) ffPrintLocalIp,
|
||||
.generateJsonResult = (void*) ffGenerateLocalIpJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateLocalIpJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"IPv4 address", "ipv4"},
|
||||
{"IPv6 address", "ipv6"},
|
||||
{"MAC address", "mac"},
|
||||
{"Interface name", "ifname"},
|
||||
{"Is default route", "is-default-route"},
|
||||
{"MTU size in bytes", "mtu"},
|
||||
{"Link speed (formatted)", "speed"},
|
||||
{"Interface flags", "flags"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitLocalIpOptions(FFLocalIpOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_LOCALIP_MODULE_NAME,
|
||||
"List local IP addresses (v4 or v6), MAC addresses, etc",
|
||||
ffParseLocalIpCommandOptions,
|
||||
ffParseLocalIpJsonObject,
|
||||
ffPrintLocalIp,
|
||||
ffGenerateLocalIpJsonResult,
|
||||
ffPrintLocalIpHelpFormat,
|
||||
ffGenerateLocalIpJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->showType = FF_LOCALIP_TYPE_IPV4_BIT | FF_LOCALIP_TYPE_PREFIX_LEN_BIT
|
||||
|
||||
+18
-24
@@ -6,8 +6,6 @@
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#define FF_MEDIA_NUM_FORMAT_ARGS 5
|
||||
|
||||
static inline bool shouldIgnoreChar(char c)
|
||||
{
|
||||
return isblank(c) || c == '-' || c == '.';
|
||||
@@ -95,7 +93,7 @@ void ffPrintMedia(FFMediaOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_MEDIA_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(songPretty, "combined"),
|
||||
FF_FORMAT_ARG(media->song, "title"),
|
||||
FF_FORMAT_ARG(media->artist, "artist"),
|
||||
@@ -157,30 +155,26 @@ void ffGenerateMediaJsonResult(FF_MAYBE_UNUSED FFMediaOptions* options, yyjson_m
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "status", &media->status);
|
||||
}
|
||||
|
||||
void ffPrintMediaHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_MEDIA_MODULE_NAME, "{3} - {1} ({5})", FF_MEDIA_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Pretty media name - combined",
|
||||
"Media name - title",
|
||||
"Artist name - artist",
|
||||
"Album name - album",
|
||||
"Status - status",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_MEDIA_MODULE_NAME,
|
||||
.description = "Print playing song name",
|
||||
.parseCommandOptions = (void*) ffParseMediaCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseMediaJsonObject,
|
||||
.printModule = (void*) ffPrintMedia,
|
||||
.generateJsonResult = (void*) ffGenerateMediaJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateMediaJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Pretty media name", "combined"},
|
||||
{"Media name", "title"},
|
||||
{"Artist name", "artist"},
|
||||
{"Album name", "album"},
|
||||
{"Status", "status"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitMediaOptions(FFMediaOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_MEDIA_MODULE_NAME,
|
||||
"Print playing song name",
|
||||
ffParseMediaCommandOptions,
|
||||
ffParseMediaJsonObject,
|
||||
ffPrintMedia,
|
||||
ffGenerateMediaJsonResult,
|
||||
ffPrintMediaHelpFormat,
|
||||
ffGenerateMediaJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+17
-23
@@ -6,8 +6,6 @@
|
||||
#include "modules/memory/memory.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_MEMORY_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintMemory(FFMemoryOptions* options)
|
||||
{
|
||||
FFMemoryResult storage = {};
|
||||
@@ -64,7 +62,7 @@ void ffPrintMemory(FFMemoryOptions* options)
|
||||
if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
ffPercentAppendBar(&percentageBar, percentage, options->percent, &options->moduleArgs);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_MEMORY_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(usedPretty, "used"),
|
||||
FF_FORMAT_ARG(totalPretty, "total"),
|
||||
FF_FORMAT_ARG(percentageNum, "percentage"),
|
||||
@@ -132,29 +130,25 @@ void ffGenerateMemoryJsonResult(FF_MAYBE_UNUSED FFMemoryOptions* options, yyjson
|
||||
yyjson_mut_obj_add_uint(doc, obj, "used", storage.bytesUsed);
|
||||
}
|
||||
|
||||
void ffPrintMemoryHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_MEMORY_MODULE_NAME, "{1} / {2} ({3})", FF_MEMORY_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Used size - used",
|
||||
"Total size - total",
|
||||
"Percentage used (num) - percentage",
|
||||
"Percentage used (bar) - percentage-bar",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_MEMORY_MODULE_NAME,
|
||||
.description = "Print system memory usage info",
|
||||
.parseCommandOptions = (void*) ffParseMemoryCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseMemoryJsonObject,
|
||||
.printModule = (void*) ffPrintMemory,
|
||||
.generateJsonResult = (void*) ffGenerateMemoryJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateMemoryJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Used size", "used"},
|
||||
{"Total size", "total"},
|
||||
{"Percentage used (num)", "percentage"},
|
||||
{"Percentage used (bar)", "percentage-bar"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitMemoryOptions(FFMemoryOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_MEMORY_MODULE_NAME,
|
||||
"Print system memory usage info",
|
||||
ffParseMemoryCommandOptions,
|
||||
ffParseMemoryJsonObject,
|
||||
ffPrintMemory,
|
||||
ffGenerateMemoryJsonResult,
|
||||
ffPrintMemoryHelpFormat,
|
||||
ffGenerateMemoryJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
options->percent = (FFPercentageModuleConfig) { 50, 80, 0 };
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#define FF_MONITOR_NUM_FORMAT_ARGS 12
|
||||
|
||||
void ffPrintMonitor(FFMonitorOptions* options)
|
||||
{
|
||||
const FFDisplayServerResult* result = ffConnectDisplayServer();
|
||||
@@ -36,7 +34,7 @@ void ffPrintMonitor(FFMonitorOptions* options)
|
||||
else
|
||||
{
|
||||
uint32_t moduleIndex = result->displays.length == 1 ? 0 : index + 1;
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 3, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(moduleIndex, "index"),
|
||||
FF_FORMAT_ARG(display->name, "name"),
|
||||
FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"),
|
||||
@@ -67,7 +65,7 @@ void ffPrintMonitor(FFMonitorOptions* options)
|
||||
else
|
||||
buf[0] = '\0';
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_MONITOR_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(display->name, "name"),
|
||||
FF_FORMAT_ARG(display->width, "width"),
|
||||
FF_FORMAT_ARG(display->height, "height"),
|
||||
@@ -128,37 +126,33 @@ void ffGenerateMonitorJsonResult(FF_MAYBE_UNUSED FFMonitorOptions* options, yyjs
|
||||
yyjson_mut_obj_add_str(doc, module, "error", "Monitor module is an alias of Display module");
|
||||
}
|
||||
|
||||
void ffPrintMonitorHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_MONITOR_MODULE_NAME, "{2}x{3} px - {4}x{5} mm ({6} inches, {7} ppi)", FF_MONITOR_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Display name - name",
|
||||
"Native resolution width in pixels - width",
|
||||
"Native resolution height in pixels - height",
|
||||
"Physical width in millimeters - physical-width",
|
||||
"Physical height in millimeters - physical-height",
|
||||
"Physical diagonal length in inches - inch",
|
||||
"Pixels per inch (PPI) - ppi",
|
||||
"Year of manufacturing - manufacture-year",
|
||||
"Nth week of manufacturing in the year - manufacture-week",
|
||||
"Serial number - serial",
|
||||
"Maximum refresh rate in Hz - refresh-rate",
|
||||
"True if the display is HDR compatible - hdr-compatible",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_MONITOR_MODULE_NAME,
|
||||
.description = "Alias of Display module",
|
||||
.parseCommandOptions = (void*) ffParseMonitorCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseMonitorJsonObject,
|
||||
.printModule = (void*) ffPrintMonitor,
|
||||
.generateJsonResult = (void*) ffGenerateMonitorJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateMonitorJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Display name", "name"},
|
||||
{"Native resolution width in pixels", "width"},
|
||||
{"Native resolution height in pixels", "height"},
|
||||
{"Physical width in millimeters", "physical-width"},
|
||||
{"Physical height in millimeters", "physical-height"},
|
||||
{"Physical diagonal length in inches", "inch"},
|
||||
{"Pixels per inch (PPI)", "ppi"},
|
||||
{"Year of manufacturing", "manufacture-year"},
|
||||
{"Nth week of manufacturing in the year", "manufacture-week"},
|
||||
{"Serial number", "serial"},
|
||||
{"Maximum refresh rate in Hz", "refresh-rate"},
|
||||
{"True if the display is HDR compatible", "hdr-compatible"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitMonitorOptions(FFMonitorOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_MONITOR_MODULE_NAME,
|
||||
"Alias of Display module",
|
||||
ffParseMonitorCommandOptions,
|
||||
ffParseMonitorJsonObject,
|
||||
ffPrintMonitor,
|
||||
ffGenerateMonitorJsonResult,
|
||||
ffPrintMonitorHelpFormat,
|
||||
ffGenerateMonitorJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+15
-21
@@ -5,8 +5,6 @@
|
||||
#include "modules/mouse/mouse.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_MOUSE_NUM_FORMAT_ARGS 2
|
||||
|
||||
static void printDevice(FFMouseOptions* options, const FFMouseDevice* device, uint8_t index)
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
@@ -16,7 +14,7 @@ static void printDevice(FFMouseOptions* options, const FFMouseDevice* device, ui
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_MOUSE_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_MOUSE_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_MOUSE_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(device->name, "name"),
|
||||
FF_FORMAT_ARG(device->serial, "serial"),
|
||||
}));
|
||||
@@ -112,27 +110,23 @@ void ffGenerateMouseJsonResult(FF_MAYBE_UNUSED FFMouseOptions* options, yyjson_m
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintMouseHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_MOUSE_MODULE_NAME, "{1} ({3})", FF_MOUSE_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Name - name",
|
||||
"Serial number - serial",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_MOUSE_MODULE_NAME,
|
||||
.description = "List connected mouses",
|
||||
.parseCommandOptions = (void*) ffParseMouseCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseMouseJsonObject,
|
||||
.printModule = (void*) ffPrintMouse,
|
||||
.generateJsonResult = (void*) ffGenerateMouseJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateMouseJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Mouse name", "name"},
|
||||
{"Mouse serial number", "serial"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitMouseOptions(FFMouseOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_MOUSE_MODULE_NAME,
|
||||
"List connected mouses",
|
||||
ffParseMouseCommandOptions,
|
||||
ffParseMouseJsonObject,
|
||||
ffPrintMouse,
|
||||
ffGenerateMouseJsonResult,
|
||||
ffPrintMouseHelpFormat,
|
||||
ffGenerateMouseJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+26
-31
@@ -6,7 +6,6 @@
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_NETIO_DISPLAY_NAME "Network IO"
|
||||
#define FF_NETIO_NUM_FORMAT_ARGS 12
|
||||
|
||||
static int sortInfs(const FFNetIOResult* left, const FFNetIOResult* right)
|
||||
{
|
||||
@@ -25,7 +24,7 @@ static void formatKey(const FFNetIOOptions* options, FFNetIOResult* inf, uint32_
|
||||
else
|
||||
{
|
||||
ffStrbufClear(key);
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, 3, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(index, "index"),
|
||||
FF_FORMAT_ARG(inf->name, "name"),
|
||||
FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"),
|
||||
@@ -80,7 +79,7 @@ void ffPrintNetIO(FFNetIOOptions* options)
|
||||
ffParseSize(inf->txBytes, &buffer2);
|
||||
if (!options->detectTotal) ffStrbufAppendS(&buffer2, "/s");
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_NETIO_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(buffer, "rx-size"),
|
||||
FF_FORMAT_ARG(buffer2, "tx-size"),
|
||||
FF_FORMAT_ARG(inf->name, "ifname"),
|
||||
@@ -229,37 +228,33 @@ void ffGenerateNetIOJsonResult(FFNetIOOptions* options, yyjson_mut_doc* doc, yyj
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintNetIOHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_NETIO_MODULE_NAME, "{1} (IN) - {2} (OUT)", FF_NETIO_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Size of data received [per second] (formatted) - rx-size",
|
||||
"Size of data sent [per second] (formatted) - tx-size",
|
||||
"Interface name - ifname",
|
||||
"Is default route - is-default-route",
|
||||
"Size of data received [per second] (in bytes) - rx-bytes",
|
||||
"Size of data sent [per second] (in bytes) - tx-bytes",
|
||||
"Number of packets received [per second] - rx-packets",
|
||||
"Number of packets sent [per second] - tx-packets",
|
||||
"Number of errors received [per second] - rx-errors",
|
||||
"Number of errors sent [per second] - tx-errors",
|
||||
"Number of packets dropped when receiving [per second] - rx-drops",
|
||||
"Number of packets dropped when sending [per second] - tx-drops",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_NETIO_MODULE_NAME,
|
||||
.description = "Print network I/O throughput",
|
||||
.parseCommandOptions = (void*) ffParseNetIOCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseNetIOJsonObject,
|
||||
.printModule = (void*) ffPrintNetIO,
|
||||
.generateJsonResult = (void*) ffGenerateNetIOJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateNetIOJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Size of data received [per second] (formatted)", "rx-size"},
|
||||
{"Size of data sent [per second] (formatted)", "tx-size"},
|
||||
{"Interface name", "ifname"},
|
||||
{"Is default route", "is-default-route"},
|
||||
{"Size of data received [per second] (in bytes)", "rx-bytes"},
|
||||
{"Size of data sent [per second] (in bytes)", "tx-bytes"},
|
||||
{"Number of packets received [per second]", "rx-packets"},
|
||||
{"Number of packets sent [per second]", "tx-packets"},
|
||||
{"Number of errors received [per second]", "rx-errors"},
|
||||
{"Number of errors sent [per second]", "tx-errors"},
|
||||
{"Number of packets dropped when receiving [per second]", "rx-drops"},
|
||||
{"Number of packets dropped when sending [per second]", "tx-drops"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitNetIOOptions(FFNetIOOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_NETIO_MODULE_NAME,
|
||||
"Print network I/O throughput",
|
||||
ffParseNetIOCommandOptions,
|
||||
ffParseNetIOJsonObject,
|
||||
ffPrintNetIO,
|
||||
ffGenerateNetIOJsonResult,
|
||||
ffPrintNetIOHelpFormat,
|
||||
ffGenerateNetIOJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
ffStrbufInit(&options->namePrefix);
|
||||
|
||||
+16
-22
@@ -5,8 +5,6 @@
|
||||
#include "modules/opencl/opencl.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_OPENCL_NUM_FORMAT_ARGS 3
|
||||
|
||||
void ffPrintOpenCL(FFOpenCLOptions* options)
|
||||
{
|
||||
FFOpenCLResult* result = ffDetectOpenCL();
|
||||
@@ -24,7 +22,7 @@ void ffPrintOpenCL(FFOpenCLOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_OPENCL_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result->version, "version"),
|
||||
FF_FORMAT_ARG(result->name, "name"),
|
||||
FF_FORMAT_ARG(result->vendor, "vendor"),
|
||||
@@ -130,28 +128,24 @@ void ffGenerateOpenCLJsonResult(FF_MAYBE_UNUSED FFOpenCLOptions* options, yyjson
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintOpenCLHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_OPENCL_MODULE_NAME, "{1}", FF_OPENCL_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Platform version - version",
|
||||
"Platform name - name",
|
||||
"Platform vendor - vendor",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_OPENCL_MODULE_NAME,
|
||||
.description = "Print highest OpenCL version supported by the GPU",
|
||||
.parseCommandOptions = (void*) ffParseOpenCLCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseOpenCLJsonObject,
|
||||
.printModule = (void*) ffPrintOpenCL,
|
||||
.generateJsonResult = (void*) ffGenerateOpenCLJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateOpenCLJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Platform version", "version"},
|
||||
{"Platform name", "name"},
|
||||
{"Platform vendor", "vendor"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitOpenCLOptions(FFOpenCLOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_OPENCL_MODULE_NAME,
|
||||
"Print highest OpenCL version supported by the GPU",
|
||||
ffParseOpenCLCommandOptions,
|
||||
ffParseOpenCLJsonObject,
|
||||
ffPrintOpenCL,
|
||||
ffGenerateOpenCLJsonResult,
|
||||
ffPrintOpenCLHelpFormat,
|
||||
ffGenerateOpenCLJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+18
-24
@@ -4,8 +4,6 @@
|
||||
#include "modules/opengl/opengl.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_OPENGL_NUM_FORMAT_ARGS 5
|
||||
|
||||
void ffPrintOpenGL(FFOpenGLOptions* options)
|
||||
{
|
||||
FFOpenGLResult result;
|
||||
@@ -29,7 +27,7 @@ void ffPrintOpenGL(FFOpenGLOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_OPENGL_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result.version, "version"),
|
||||
FF_FORMAT_ARG(result.renderer, "renderer"),
|
||||
FF_FORMAT_ARG(result.vendor, "vendor"),
|
||||
@@ -159,30 +157,26 @@ void ffGenerateOpenGLJsonResult(FF_MAYBE_UNUSED FFOpenGLOptions* options, yyjson
|
||||
ffStrbufDestroy(&result.library);
|
||||
}
|
||||
|
||||
void ffPrintOpenGLHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_OPENGL_MODULE_NAME, "{1}", FF_OPENGL_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"version - version",
|
||||
"renderer - renderer",
|
||||
"vendor - vendor",
|
||||
"shading language version - slv",
|
||||
"ogl library used - library",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_OPENGL_MODULE_NAME,
|
||||
.description = "Print highest OpenGL version supported by the GPU",
|
||||
.parseCommandOptions = (void*) ffParseOpenGLCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseOpenGLJsonObject,
|
||||
.printModule = (void*) ffPrintOpenGL,
|
||||
.generateJsonResult = (void*) ffGenerateOpenGLJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateOpenGLJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"OpenGL version", "version"},
|
||||
{"OpenGL renderer", "renderer"},
|
||||
{"OpenGL vendor", "vendor"},
|
||||
{"OpenGL shading language version", "slv"},
|
||||
{"OpenGL library used", "library"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitOpenGLOptions(FFOpenGLOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_OPENGL_MODULE_NAME,
|
||||
"Print highest OpenGL version supported by the GPU",
|
||||
ffParseOpenGLCommandOptions,
|
||||
ffParseOpenGLJsonObject,
|
||||
ffPrintOpenGL,
|
||||
ffGenerateOpenGLJsonResult,
|
||||
ffPrintOpenGLHelpFormat,
|
||||
ffGenerateOpenGLJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->library = FF_OPENGL_LIBRARY_AUTO;
|
||||
|
||||
+25
-31
@@ -7,8 +7,6 @@
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#define FF_OS_NUM_FORMAT_ARGS 12
|
||||
|
||||
static void buildOutputDefault(const FFOSResult* os, FFstrbuf* result)
|
||||
{
|
||||
//Create the basic output
|
||||
@@ -111,7 +109,7 @@ void ffPrintOS(FFOSOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_OS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_OS_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_OS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(instance.state.platform.sysinfo.name, "sysname"),
|
||||
FF_FORMAT_ARG(os->name, "name"),
|
||||
FF_FORMAT_ARG(os->prettyName, "pretty-name"),
|
||||
@@ -186,37 +184,33 @@ void ffGenerateOSJsonResult(FF_MAYBE_UNUSED FFOSOptions* options, yyjson_mut_doc
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "versionID", &os->versionID);
|
||||
}
|
||||
|
||||
void ffPrintOSHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_OS_MODULE_NAME, "{3} {10} {12}", FF_OS_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Name of the kernel (Linux, WIN32_NT, Darwin, FreeBSD) - sysname",
|
||||
"Name of the OS - name",
|
||||
"Pretty name of the OS - pretty-name",
|
||||
"ID of the OS - id",
|
||||
"ID like of the OS - id-like",
|
||||
"Variant of the OS - variant",
|
||||
"Variant ID of the OS - variant-id",
|
||||
"Version of the OS - version",
|
||||
"Version ID of the OS - version-id",
|
||||
"Version codename of the OS - codename",
|
||||
"Build ID of the OS - build-id",
|
||||
"Architecture of the OS - arch",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_OS_MODULE_NAME,
|
||||
.description = "Print operating system name and version",
|
||||
.parseCommandOptions = (void*) ffParseOSCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseOSJsonObject,
|
||||
.printModule = (void*) ffPrintOS,
|
||||
.generateJsonResult = (void*) ffGenerateOSJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateOSJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Name of the kernel", "sysname"},
|
||||
{"Name of the OS", "name"},
|
||||
{"Pretty name of the OS", "pretty-name"},
|
||||
{"ID of the OS", "id"},
|
||||
{"ID like of the OS", "id-like"},
|
||||
{"Variant of the OS", "variant"},
|
||||
{"Variant ID of the OS", "variant-id"},
|
||||
{"Version of the OS", "version"},
|
||||
{"Version ID of the OS", "version-id"},
|
||||
{"Version codename of the OS", "codename"},
|
||||
{"Build ID of the OS", "build-id"},
|
||||
{"Architecture of the OS", "arch"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitOSOptions(FFOSOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_OS_MODULE_NAME,
|
||||
"Print operating system name and version",
|
||||
ffParseOSCommandOptions,
|
||||
ffParseOSJsonObject,
|
||||
ffPrintOS,
|
||||
ffGenerateOSJsonResult,
|
||||
ffPrintOSHelpFormat,
|
||||
ffGenerateOSJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs,
|
||||
#ifdef _WIN32
|
||||
""
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include "modules/packages/packages.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_PACKAGES_NUM_FORMAT_ARGS 40
|
||||
|
||||
void ffPrintPackages(FFPackagesOptions* options)
|
||||
{
|
||||
FFPackagesResult counts = {};
|
||||
@@ -84,7 +82,7 @@ void ffPrintPackages(FFPackagesOptions* options)
|
||||
uint32_t flatpakAll = counts.flatpakSystem + counts.flatpakUser;
|
||||
uint32_t brewAll = counts.brew + counts.brewCask;
|
||||
uint32_t guixAll = counts.guixSystem + counts.guixUser + counts.guixHome;
|
||||
FF_PRINT_FORMAT_CHECKED(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_PACKAGES_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(counts.all, "all"),
|
||||
FF_FORMAT_ARG(counts.pacman, "pacman"),
|
||||
FF_FORMAT_ARG(counts.pacmanBranch, "pacman-branch"),
|
||||
@@ -437,65 +435,61 @@ void ffGeneratePackagesJsonResult(FF_MAYBE_UNUSED FFPackagesOptions* options, yy
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "pacmanBranch", &counts.pacmanBranch);
|
||||
}
|
||||
|
||||
void ffPrintPackagesHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PACKAGES_MODULE_NAME, "{2} (pacman){?3}[{3}]{?}, {4} (dpkg), {5} (rpm), {6} (emerge), {7} (eopkg), {8} (xbps), {9} (nix-system), {10} (nix-user), {11} (nix-default), {12} (apk), {13} (pkg), {14} (flatpak-system), {15} (flatpack-user), {16} (snap), {17} (brew), {18} (brew-cask), {19} (MacPorts), {20} (scoop), {21} (choco), {22} (pkgtool), {23} (paludis), {24} (winget), {25} (opkg), {26} (am), {27} (sorcery), {28} (lpkg), {29} (lpkgbuild), {30} (guix-system), {31} (guix-user), {32} (guix-home), {33} (linglong), {34} (pacstall), {35} (mport), {36} qi", FF_PACKAGES_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Number of all packages - all",
|
||||
"Number of pacman packages - pacman",
|
||||
"Pacman branch on manjaro - pacman-branch",
|
||||
"Number of dpkg packages - dpkg",
|
||||
"Number of rpm packages - rpm",
|
||||
"Number of emerge packages - emerge",
|
||||
"Number of eopkg packages - eopkg",
|
||||
"Number of xbps packages - xbps",
|
||||
"Number of nix-system packages - nix-system",
|
||||
"Number of nix-user packages - nix-user",
|
||||
"Number of nix-default packages - nix-default",
|
||||
"Number of apk packages - apk",
|
||||
"Number of pkg packages - pkg",
|
||||
"Number of flatpak-system app packages - flatpak-system",
|
||||
"Number of flatpak-user app packages - flatpak-user",
|
||||
"Number of snap packages - snap",
|
||||
"Number of brew packages - brew",
|
||||
"Number of brew-cask packages - brew-cask",
|
||||
"Number of macports packages - macports",
|
||||
"Number of scoop packages - scoop",
|
||||
"Number of choco packages - choco",
|
||||
"Number of pkgtool packages - pkgtool",
|
||||
"Number of paludis packages - paludis",
|
||||
"Number of winget packages - winget",
|
||||
"Number of opkg packages - opkg",
|
||||
"Number of am packages - am",
|
||||
"Number of sorcery packages - sorcery",
|
||||
"Number of lpkg packages - lpkg",
|
||||
"Number of lpkgbuild packages - lpkgbuild",
|
||||
"Number of guix-system packages - guix-system",
|
||||
"Number of guix-user packages - guix-user",
|
||||
"Number of guix-home packages - guix-home",
|
||||
"Number of linglong packages - linglong",
|
||||
"Number of pacstall packages - pacstall",
|
||||
"Number of mport packages - mport",
|
||||
"Number of qi packages - qi",
|
||||
"Total number of all nix packages - nix-all",
|
||||
"Total number of all flatpak app packages - flatpak-all",
|
||||
"Total number of all brew packages - brew-all",
|
||||
"Total number of all guix packages - guix-all",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_PACKAGES_MODULE_NAME,
|
||||
.description = "List installed package managers and count of installed packages",
|
||||
.parseCommandOptions = (void*) ffParsePackagesCommandOptions,
|
||||
.parseJsonObject = (void*) ffParsePackagesJsonObject,
|
||||
.printModule = (void*) ffPrintPackages,
|
||||
.generateJsonResult = (void*) ffGeneratePackagesJsonResult,
|
||||
.generateJsonConfig = (void*) ffGeneratePackagesJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Number of all packages", "all"},
|
||||
{"Number of pacman packages", "pacman"},
|
||||
{"Pacman branch on manjaro", "pacman-branch"},
|
||||
{"Number of dpkg packages", "dpkg"},
|
||||
{"Number of rpm packages", "rpm"},
|
||||
{"Number of emerge packages", "emerge"},
|
||||
{"Number of eopkg packages", "eopkg"},
|
||||
{"Number of xbps packages", "xbps"},
|
||||
{"Number of nix-system packages", "nix-system"},
|
||||
{"Number of nix-user packages", "nix-user"},
|
||||
{"Number of nix-default packages", "nix-default"},
|
||||
{"Number of apk packages", "apk"},
|
||||
{"Number of pkg packages", "pkg"},
|
||||
{"Number of flatpak-system app packages", "flatpak-system"},
|
||||
{"Number of flatpak-user app packages", "flatpak-user"},
|
||||
{"Number of snap packages", "snap"},
|
||||
{"Number of brew packages", "brew"},
|
||||
{"Number of brew-cask packages", "brew-cask"},
|
||||
{"Number of macports packages", "macports"},
|
||||
{"Number of scoop packages", "scoop"},
|
||||
{"Number of choco packages", "choco"},
|
||||
{"Number of pkgtool packages", "pkgtool"},
|
||||
{"Number of paludis packages", "paludis"},
|
||||
{"Number of winget packages", "winget"},
|
||||
{"Number of opkg packages", "opkg"},
|
||||
{"Number of am packages", "am"},
|
||||
{"Number of sorcery packages", "sorcery"},
|
||||
{"Number of lpkg packages", "lpkg"},
|
||||
{"Number of lpkgbuild packages", "lpkgbuild"},
|
||||
{"Number of guix-system packages", "guix-system"},
|
||||
{"Number of guix-user packages", "guix-user"},
|
||||
{"Number of guix-home packages", "guix-home"},
|
||||
{"Number of linglong packages", "linglong"},
|
||||
{"Number of pacstall packages", "pacstall"},
|
||||
{"Number of mport packages", "mport"},
|
||||
{"Number of qi packages", "qi"},
|
||||
{"Total number of all nix packages", "nix-all"},
|
||||
{"Total number of all flatpak app packages", "flatpak-all"},
|
||||
{"Total number of all brew packages", "brew-all"},
|
||||
{"Total number of all guix packages", "guix-all"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitPackagesOptions(FFPackagesOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_PACKAGES_MODULE_NAME,
|
||||
"List installed package managers and count of installed packages",
|
||||
ffParsePackagesCommandOptions,
|
||||
ffParsePackagesJsonObject,
|
||||
ffPrintPackages,
|
||||
ffGeneratePackagesJsonResult,
|
||||
ffPrintPackagesHelpFormat,
|
||||
ffGeneratePackagesJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->disabled = FF_PACKAGES_DISABLE_LIST;
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_PHYSICALDISK_DISPLAY_NAME "Physical Disk"
|
||||
#define FF_PHYSICALDISK_NUM_FORMAT_ARGS 10
|
||||
|
||||
static int sortDevices(const FFPhysicalDiskResult* left, const FFPhysicalDiskResult* right)
|
||||
{
|
||||
@@ -23,7 +22,7 @@ static void formatKey(const FFPhysicalDiskOptions* options, FFPhysicalDiskResult
|
||||
else
|
||||
{
|
||||
ffStrbufClear(key);
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, 4, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(index, "index"),
|
||||
FF_FORMAT_ARG(dev->name, "name"),
|
||||
FF_FORMAT_ARG(dev->devPath, "dev-path"),
|
||||
@@ -108,13 +107,13 @@ void ffPrintPhysicalDisk(FFPhysicalDiskOptions* options)
|
||||
ffTempsAppendNum(dev->temperature, &tempStr, options->tempConfig, &options->moduleArgs);
|
||||
if (dev->type & FF_PHYSICALDISK_TYPE_READWRITE)
|
||||
readOnlyType = "Read-write";
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_PHYSICALDISK_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(buffer, "size"),
|
||||
FF_FORMAT_ARG(dev->name, "name"),
|
||||
FF_FORMAT_ARG(dev->interconnect, "interconnect"),
|
||||
FF_FORMAT_ARG(physicalType, "type"),
|
||||
FF_FORMAT_ARG(dev->devPath, "dev-path"),
|
||||
FF_FORMAT_ARG(dev->serial, "serial"),
|
||||
FF_FORMAT_ARG(physicalType, "physical-type"),
|
||||
FF_FORMAT_ARG(removableType, "removable-type"),
|
||||
FF_FORMAT_ARG(readOnlyType, "readonly-type"),
|
||||
FF_FORMAT_ARG(dev->revision, "revision"),
|
||||
@@ -250,35 +249,31 @@ void ffGeneratePhysicalDiskJsonResult(FFPhysicalDiskOptions* options, yyjson_mut
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintPhysicalDiskHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PHYSICALDISK_MODULE_NAME, "{1} [{6}, {7}, {8}]", FF_PHYSICALDISK_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Device size (formatted) - ",
|
||||
"Device name",
|
||||
"Device interconnect type",
|
||||
"Device raw file path",
|
||||
"Serial number",
|
||||
"Device kind (SSD or HDD)",
|
||||
"Device kind (Removable or Fixed)",
|
||||
"Device kind (Read-only or Read-write)",
|
||||
"Product revision",
|
||||
"Device temperature (formatted)",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_PHYSICALDISK_MODULE_NAME,
|
||||
.description = "Print physical disk information",
|
||||
.parseCommandOptions = (void*) ffParsePhysicalDiskCommandOptions,
|
||||
.parseJsonObject = (void*) ffParsePhysicalDiskJsonObject,
|
||||
.printModule = (void*) ffPrintPhysicalDisk,
|
||||
.generateJsonResult = (void*) ffGeneratePhysicalDiskJsonResult,
|
||||
.generateJsonConfig = (void*) ffGeneratePhysicalDiskJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Device size (formatted)", "size"},
|
||||
{"Device name", "name"},
|
||||
{"Device interconnect type", "interconnect"},
|
||||
{"Device raw file path", "dev-path"},
|
||||
{"Serial number", "serial"},
|
||||
{"Device kind (SSD or HDD)", "physical-type"},
|
||||
{"Device kind (Removable or Fixed)", "removable-type"},
|
||||
{"Device kind (Read-only or Read-write)", "readonly-type"},
|
||||
{"Product revision", "revision"},
|
||||
{"Device temperature (formatted)", "temperature"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitPhysicalDiskOptions(FFPhysicalDiskOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_PHYSICALDISK_MODULE_NAME,
|
||||
"Print physical disk information",
|
||||
ffParsePhysicalDiskCommandOptions,
|
||||
ffParsePhysicalDiskJsonObject,
|
||||
ffPrintPhysicalDisk,
|
||||
ffGeneratePhysicalDiskJsonResult,
|
||||
ffPrintPhysicalDiskHelpFormat,
|
||||
ffGeneratePhysicalDiskJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
ffStrbufInit(&options->namePrefix);
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "modules/physicalmemory/physicalmemory.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_PHYSICALMEMORY_NUM_FORMAT_ARGS 11
|
||||
#define FF_PHYSICALMEMORY_DISPLAY_NAME "Physical Memory"
|
||||
|
||||
void ffPrintPhysicalMemory(FFPhysicalMemoryOptions* options)
|
||||
@@ -54,7 +53,7 @@ void ffPrintPhysicalMemory(FFPhysicalMemoryOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_PHYSICALMEMORY_DISPLAY_NAME, (uint8_t) i, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_PHYSICALMEMORY_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_PHYSICALMEMORY_DISPLAY_NAME, (uint8_t) i, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(device->size, "bytes"),
|
||||
FF_FORMAT_ARG(prettySize, "size"),
|
||||
FF_FORMAT_ARG(device->maxSpeed, "max-speed"),
|
||||
@@ -154,36 +153,31 @@ void ffGeneratePhysicalMemoryJsonResult(FF_MAYBE_UNUSED FFPhysicalMemoryOptions*
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintPhysicalMemoryHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PHYSICALMEMORY_MODULE_NAME, "{7} {5}-{3}: {2}, running at {4} MT/s", FF_PHYSICALMEMORY_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Size (in bytes) - bytes",
|
||||
"Size formatted - size",
|
||||
"Max speed (in MT/s) - max-speed",
|
||||
"Running speed (in MT/s) - running-speed",
|
||||
"Type (DDR4, DDR5, etc.) - type",
|
||||
"Form factor (SODIMM, DIMM, etc.) - form-factor",
|
||||
"Bank/Device Locator (BANK0/SIMM0, BANK0/SIMM1, etc.) - locator",
|
||||
"Vendor - vendor",
|
||||
"Serial number - serial",
|
||||
"Part number - part-number",
|
||||
"True if ECC enabled - is-ecc-enabled",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_PHYSICALMEMORY_MODULE_NAME,
|
||||
.description = "Print system physical memory devices",
|
||||
.parseCommandOptions = (void*) ffParsePhysicalMemoryCommandOptions,
|
||||
.parseJsonObject = (void*) ffParsePhysicalMemoryJsonObject,
|
||||
.printModule = (void*) ffPrintPhysicalMemory,
|
||||
.generateJsonConfig = (void*) ffGeneratePhysicalMemoryJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Size (in bytes)", "bytes"},
|
||||
{"Size formatted", "size"},
|
||||
{"Max speed (in MT/s)", "max-speed"},
|
||||
{"Running speed (in MT/s)", "running-speed"},
|
||||
{"Type (DDR4, DDR5, etc.)", "type"},
|
||||
{"Form factor (SODIMM, DIMM, etc.)", "form-factor"},
|
||||
{"Bank/Device Locator (BANK0/SIMM0, BANK0/SIMM1, etc.)", "locator"},
|
||||
{"Vendor", "vendor"},
|
||||
{"Serial number", "serial"},
|
||||
{"Part number", "part-number"},
|
||||
{"True if ECC enabled", "is-ecc-enabled"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitPhysicalMemoryOptions(FFPhysicalMemoryOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_PHYSICALMEMORY_MODULE_NAME,
|
||||
"Print system physical memory devices",
|
||||
ffParsePhysicalMemoryCommandOptions,
|
||||
ffParsePhysicalMemoryJsonObject,
|
||||
ffPrintPhysicalMemory,
|
||||
ffGeneratePhysicalMemoryJsonResult,
|
||||
ffPrintPhysicalMemoryHelpFormat,
|
||||
ffGeneratePhysicalMemoryJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+17
-22
@@ -7,7 +7,6 @@
|
||||
#include <ctype.h>
|
||||
|
||||
#define FF_PLAYER_DISPLAY_NAME "Media Player"
|
||||
#define FF_PLAYER_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintPlayer(FFPlayerOptions* options)
|
||||
{
|
||||
@@ -73,7 +72,7 @@ void ffPrintPlayer(FFPlayerOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_PLAYER_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(playerPretty, "player"),
|
||||
FF_FORMAT_ARG(media->player, "name"),
|
||||
FF_FORMAT_ARG(media->playerId, "id"),
|
||||
@@ -133,29 +132,25 @@ void ffGeneratePlayerJsonResult(FF_MAYBE_UNUSED FFMediaOptions* options, yyjson_
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "url", &media->url);
|
||||
}
|
||||
|
||||
void ffPrintPlayerHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PLAYER_MODULE_NAME, "{1}", FF_PLAYER_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Pretty player name - player",
|
||||
"Player name - name",
|
||||
"Player Identifier - id",
|
||||
"URL name - url",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_PLAYER_MODULE_NAME,
|
||||
.description = "Print music player name",
|
||||
.parseCommandOptions = (void*) ffParsePlayerCommandOptions,
|
||||
.parseJsonObject = (void*) ffParsePlayerJsonObject,
|
||||
.printModule = (void*) ffPrintPlayer,
|
||||
.generateJsonResult = (void*) ffGeneratePlayerJsonResult,
|
||||
.generateJsonConfig = (void*) ffGeneratePlayerJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Pretty player name", "player"},
|
||||
{"Player name", "name"},
|
||||
{"Player Identifier", "id"},
|
||||
{"URL name", "url"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitPlayerOptions(FFPlayerOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_PLAYER_MODULE_NAME,
|
||||
"Print music player name",
|
||||
ffParsePlayerCommandOptions,
|
||||
ffParsePlayerJsonObject,
|
||||
ffPrintPlayer,
|
||||
ffGeneratePlayerJsonResult,
|
||||
ffPrintPlayerHelpFormat,
|
||||
ffGeneratePlayerJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_POWERADAPTER_DISPLAY_NAME "Power Adapter"
|
||||
#define FF_POWERADAPTER_NUM_FORMAT_ARGS 6
|
||||
|
||||
void ffPrintPowerAdapter(FFPowerAdapterOptions* options)
|
||||
{
|
||||
@@ -38,7 +37,7 @@ void ffPrintPowerAdapter(FFPowerAdapterOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_POWERADAPTER_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(result->watts, "watts"),
|
||||
FF_FORMAT_ARG(result->name, "name"),
|
||||
FF_FORMAT_ARG(result->manufacturer, "manufacturer"),
|
||||
@@ -126,31 +125,27 @@ void ffGeneratePowerAdapterJsonResult(FF_MAYBE_UNUSED FFPowerAdapterOptions* opt
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintPowerAdapterHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_POWERADAPTER_MODULE_NAME, "{1}W", FF_POWERADAPTER_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"PowerAdapter watts - watts",
|
||||
"PowerAdapter name - name",
|
||||
"PowerAdapter manufacturer - manufacturer",
|
||||
"PowerAdapter model - model",
|
||||
"PowerAdapter description - description",
|
||||
"PowerAdapter serial number - serial",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_POWERADAPTER_MODULE_NAME,
|
||||
.description = "Print power adapter name and charging watts",
|
||||
.parseCommandOptions = (void*) ffParsePowerAdapterCommandOptions,
|
||||
.parseJsonObject = (void*) ffParsePowerAdapterJsonObject,
|
||||
.printModule = (void*) ffPrintPowerAdapter,
|
||||
.generateJsonResult = (void*) ffGeneratePowerAdapterJsonResult,
|
||||
.generateJsonConfig = (void*) ffGeneratePowerAdapterJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Power adapter watts", "watts"},
|
||||
{"Power adapter name", "name"},
|
||||
{"Power adapter manufacturer", "manufacturer"},
|
||||
{"Power adapter model", "model"},
|
||||
{"Power adapter description", "description"},
|
||||
{"Power adapter serial number", "serial"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitPowerAdapterOptions(FFPowerAdapterOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_POWERADAPTER_MODULE_NAME,
|
||||
"Print power adapter name and charging watts",
|
||||
ffParsePowerAdapterCommandOptions,
|
||||
ffParsePowerAdapterJsonObject,
|
||||
ffPrintPowerAdapter,
|
||||
ffGeneratePowerAdapterJsonResult,
|
||||
ffPrintPowerAdapterHelpFormat,
|
||||
ffGeneratePowerAdapterJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include "modules/processes/processes.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_PROCESSES_NUM_FORMAT_ARGS 1
|
||||
|
||||
void ffPrintProcesses(FFProcessesOptions* options)
|
||||
{
|
||||
uint32_t numProcesses = 0;
|
||||
@@ -25,7 +23,7 @@ void ffPrintProcesses(FFProcessesOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_PROCESSES_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(numProcesses, "result")
|
||||
}));
|
||||
}
|
||||
@@ -80,26 +78,22 @@ void ffGenerateProcessesJsonResult(FF_MAYBE_UNUSED FFProcessesOptions* options,
|
||||
yyjson_mut_obj_add_uint(doc, module, "result", result);
|
||||
}
|
||||
|
||||
void ffPrintProcessesHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PROCESSES_MODULE_NAME, "{1}", FF_PROCESSES_NUM_FORMAT_ARGS, (const char* []) {
|
||||
"Proecess count - result"
|
||||
});
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_PROCESSES_MODULE_NAME,
|
||||
.description = "Print number of running processes",
|
||||
.parseCommandOptions = (void*) ffParseProcessesCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseProcessesJsonObject,
|
||||
.printModule = (void*) ffPrintProcesses,
|
||||
.generateJsonResult = (void*) ffGenerateProcessesJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateProcessesJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Process count", "result"}
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitProcessesOptions(FFProcessesOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_PROCESSES_MODULE_NAME,
|
||||
"Count running processes",
|
||||
ffParseProcessesCommandOptions,
|
||||
ffParseProcessesJsonObject,
|
||||
ffPrintProcesses,
|
||||
ffGenerateProcessesJsonResult,
|
||||
ffPrintProcessesHelpFormat,
|
||||
ffGenerateProcessesJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_PUBLICIP_DISPLAY_NAME "Public IP"
|
||||
#define FF_PUBLICIP_NUM_FORMAT_ARGS 2
|
||||
|
||||
void ffPrintPublicIp(FFPublicIpOptions* options)
|
||||
{
|
||||
@@ -30,7 +29,7 @@ void ffPrintPublicIp(FFPublicIpOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_PUBLICIP_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result.ip, "ip"),
|
||||
FF_FORMAT_ARG(result.location, "location"),
|
||||
}));
|
||||
@@ -141,27 +140,23 @@ void ffGeneratePublicIpJsonResult(FFPublicIpOptions* options, yyjson_mut_doc* do
|
||||
ffStrbufDestroy(&result.location);
|
||||
}
|
||||
|
||||
void ffPrintPublicIpHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PUBLICIP_MODULE_NAME, "{1} ({2})", FF_PUBLICIP_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Public IP address - ip",
|
||||
"Location - location",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_PUBLICIP_MODULE_NAME,
|
||||
.description = "Print your public IP address, etc",
|
||||
.parseCommandOptions = (void*) ffParsePublicIpCommandOptions,
|
||||
.parseJsonObject = (void*) ffParsePublicIpJsonObject,
|
||||
.printModule = (void*) ffPrintPublicIp,
|
||||
.generateJsonResult = (void*) ffGeneratePublicIpJsonResult,
|
||||
.generateJsonConfig = (void*) ffGeneratePublicIpJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Public IP address", "ip"},
|
||||
{"Location", "location"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitPublicIpOptions(FFPublicIpOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_PUBLICIP_MODULE_NAME,
|
||||
"Print your public IP address, etc",
|
||||
ffParsePublicIpCommandOptions,
|
||||
ffParsePublicIpJsonObject,
|
||||
ffPrintPublicIp,
|
||||
ffGeneratePublicIpJsonResult,
|
||||
ffPrintPublicIpHelpFormat,
|
||||
ffGeneratePublicIpJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
ffStrbufInit(&options->url);
|
||||
|
||||
@@ -178,19 +178,23 @@ void ffGenerateSeparatorJsonConfig(FFSeparatorOptions* options, yyjson_mut_doc*
|
||||
yyjson_mut_obj_add_strbuf(doc, module, "string", &options->string);
|
||||
}
|
||||
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_SEPARATOR_MODULE_NAME,
|
||||
.description = "Print a separator line",
|
||||
.parseCommandOptions = (void*) ffParseSeparatorCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseSeparatorJsonObject,
|
||||
.printModule = (void*) ffPrintSeparator,
|
||||
.generateJsonConfig = (void*) ffGenerateSeparatorJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Separator string", "string"},
|
||||
{"Output color", "outputColor"},
|
||||
{"Length", "length"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitSeparatorOptions(FFSeparatorOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_SEPARATOR_MODULE_NAME,
|
||||
"Print a separator line",
|
||||
ffParseSeparatorCommandOptions,
|
||||
ffParseSeparatorJsonObject,
|
||||
ffPrintSeparator,
|
||||
NULL,
|
||||
NULL,
|
||||
ffGenerateSeparatorJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffStrbufInitStatic(&options->string, "-");
|
||||
ffStrbufInit(&options->outputColor);
|
||||
options->length = 0;
|
||||
|
||||
+21
-27
@@ -4,8 +4,6 @@
|
||||
#include "modules/shell/shell.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_SHELL_NUM_FORMAT_ARGS 8
|
||||
|
||||
void ffPrintShell(FFShellOptions* options)
|
||||
{
|
||||
const FFShellResult* result = ffDetectShell();
|
||||
@@ -31,7 +29,7 @@ void ffPrintShell(FFShellOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_SHELL_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result->processName, "process-name"),
|
||||
FF_FORMAT_ARG(result->exe, "exe"),
|
||||
FF_FORMAT_ARG(result->exeName, "exe-name"),
|
||||
@@ -104,33 +102,29 @@ void ffGenerateShellJsonResult(FF_MAYBE_UNUSED FFShellOptions* options, yyjson_m
|
||||
yyjson_mut_obj_add_null(doc, obj, "tty");
|
||||
}
|
||||
|
||||
void ffPrintShellHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_SHELL_MODULE_NAME, "{3} {4}", FF_SHELL_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Shell process name - process-name",
|
||||
"The first argument of the command line when running the shell - exe",
|
||||
"Shell base name of arg0 - exe-name",
|
||||
"Shell version - version",
|
||||
"Shell pid - pid",
|
||||
"Shell pretty name - pretty-name",
|
||||
"Shell full exe path - exe-path",
|
||||
"Shell tty used - tty",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_SHELL_MODULE_NAME,
|
||||
.description = "Print current shell name and version",
|
||||
.parseCommandOptions = (void*) ffParseShellCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseShellJsonObject,
|
||||
.printModule = (void*) ffPrintShell,
|
||||
.generateJsonResult = (void*) ffGenerateShellJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateShellJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Shell process name", "process-name"},
|
||||
{"The first argument of the command line when running the shell", "exe"},
|
||||
{"Shell base name of arg0", "exe-name"},
|
||||
{"Shell version", "version"},
|
||||
{"Shell pid", "pid"},
|
||||
{"Shell pretty name", "pretty-name"},
|
||||
{"Shell full exe path", "exe-path"},
|
||||
{"Shell tty used", "tty"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitShellOptions(FFShellOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_SHELL_MODULE_NAME,
|
||||
"Print current shell name and version",
|
||||
ffParseShellCommandOptions,
|
||||
ffParseShellJsonObject,
|
||||
ffPrintShell,
|
||||
ffGenerateShellJsonResult,
|
||||
ffPrintShellHelpFormat,
|
||||
ffGenerateShellJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+18
-24
@@ -5,8 +5,6 @@
|
||||
#include "modules/sound/sound.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_SOUND_NUM_FORMAT_ARGS 5
|
||||
|
||||
static void printDevice(FFSoundOptions* options, const FFSoundDevice* device, uint8_t index)
|
||||
{
|
||||
FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type;
|
||||
@@ -54,7 +52,7 @@ static void printDevice(FFSoundOptions* options, const FFSoundDevice* device, ui
|
||||
if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
ffPercentAppendBar(&percentageBar, device->volume, options->percent, &options->moduleArgs);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(FF_SOUND_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_SOUND_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_SOUND_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(device->main, "is-main"),
|
||||
FF_FORMAT_ARG(device->name, "name"),
|
||||
FF_FORMAT_ARG(percentageNum, "volume-percentage"),
|
||||
@@ -229,30 +227,26 @@ void ffGenerateSoundJsonResult(FF_MAYBE_UNUSED FFSoundOptions* options, yyjson_m
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintSoundHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_SOUND_MODULE_NAME, "{2} ({3}%)", FF_SOUND_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Is main sound device - is-main",
|
||||
"Device name - name",
|
||||
"Volume (in percentage num) - volume-percentage",
|
||||
"Identifier - identifier",
|
||||
"Volume (in percentage bar) - volume-percentage-bar",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_SOUND_MODULE_NAME,
|
||||
.description = "Print sound devices, volume, etc",
|
||||
.parseCommandOptions = (void*) ffParseSoundCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseSoundJsonObject,
|
||||
.printModule = (void*) ffPrintSound,
|
||||
.generateJsonResult = (void*) ffGenerateSoundJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateSoundJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Is main sound device", "is-main"},
|
||||
{"Device name", "name"},
|
||||
{"Volume (in percentage num)", "volume-percentage"},
|
||||
{"Identifier", "identifier"},
|
||||
{"Volume (in percentage bar)", "volume-percentage-bar"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitSoundOptions(FFSoundOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_SOUND_MODULE_NAME,
|
||||
"Print sound devices, volume, etc",
|
||||
ffParseSoundCommandOptions,
|
||||
ffParseSoundJsonObject,
|
||||
ffPrintSound,
|
||||
ffGenerateSoundJsonResult,
|
||||
ffPrintSoundHelpFormat,
|
||||
ffGenerateSoundJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->soundType = FF_SOUND_TYPE_MAIN;
|
||||
|
||||
+17
-23
@@ -6,8 +6,6 @@
|
||||
#include "modules/swap/swap.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_SWAP_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintSwap(FFSwapOptions* options)
|
||||
{
|
||||
FFSwapResult storage = {};
|
||||
@@ -73,7 +71,7 @@ void ffPrintSwap(FFSwapOptions* options)
|
||||
FF_STRBUF_AUTO_DESTROY percentageBar = ffStrbufCreate();
|
||||
if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
ffPercentAppendBar(&percentageBar, percentage, options->percent, &options->moduleArgs);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_SWAP_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(usedPretty, "used"),
|
||||
FF_FORMAT_ARG(totalPretty, "total"),
|
||||
FF_FORMAT_ARG(percentageNum, "percentage"),
|
||||
@@ -141,29 +139,25 @@ void ffGenerateSwapJsonResult(FF_MAYBE_UNUSED FFSwapOptions* options, yyjson_mut
|
||||
yyjson_mut_obj_add_uint(doc, obj, "used", storage.bytesUsed);
|
||||
}
|
||||
|
||||
void ffPrintSwapHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_SWAP_MODULE_NAME, "{1} / {2} ({3})", FF_SWAP_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Used size - used",
|
||||
"Total size - total",
|
||||
"Percentage used (num) - percentage",
|
||||
"Percentage used (bar) - percentage-bar",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_SWAP_MODULE_NAME,
|
||||
.description = "Print swap (paging file) space usage",
|
||||
.parseCommandOptions = (void*) ffParseSwapCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseSwapJsonObject,
|
||||
.printModule = (void*) ffPrintSwap,
|
||||
.generateJsonResult = (void*) ffGenerateSwapJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateSwapJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Used size", "used"},
|
||||
{"Total size", "total"},
|
||||
{"Percentage used (num)", "percentage"},
|
||||
{"Percentage used (bar)", "percentage-bar"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitSwapOptions(FFSwapOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_SWAP_MODULE_NAME,
|
||||
"Print swap (paging file) space usage",
|
||||
ffParseSwapCommandOptions,
|
||||
ffParseSwapJsonObject,
|
||||
ffPrintSwap,
|
||||
ffGenerateSwapJsonResult,
|
||||
ffPrintSwapHelpFormat,
|
||||
ffGenerateSwapJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
options->percent = (FFPercentageModuleConfig) { 50, 80, 0 };
|
||||
}
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
#include "modules/terminal/terminal.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define FF_TERMINAL_NUM_FORMAT_ARGS 8
|
||||
|
||||
void ffPrintTerminal(FFTerminalOptions* options)
|
||||
{
|
||||
const FFTerminalResult* result = ffDetectTerminal();
|
||||
@@ -29,7 +25,7 @@ void ffPrintTerminal(FFTerminalOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_TERMINAL_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(result->processName, "process-name"),
|
||||
FF_FORMAT_ARG(result->exe, "exe"),
|
||||
FF_FORMAT_ARG(result->exeName, "exe-name"),
|
||||
@@ -99,33 +95,29 @@ void ffGenerateTerminalJsonResult(FF_MAYBE_UNUSED FFTerminalOptions* options, yy
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "tty", &result->tty);
|
||||
}
|
||||
|
||||
void ffPrintTerminalHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_TERMINAL_MODULE_NAME, "{5} {6}", FF_TERMINAL_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Terminal process name - process-name",
|
||||
"The first argument of the command line when running the terminal - exe",
|
||||
"Terminal base name of arg0 - exe-name",
|
||||
"Terminal pid - pid",
|
||||
"Terminal pretty name - pretty-name",
|
||||
"Terminal version - version",
|
||||
"Terminal full exe path - exe-path",
|
||||
"Terminal tty / pts used - tty",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_TERMINAL_MODULE_NAME,
|
||||
.description = "Print current terminal name and version",
|
||||
.parseCommandOptions = (void*) ffParseTerminalCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseTerminalJsonObject,
|
||||
.printModule = (void*) ffPrintTerminal,
|
||||
.generateJsonResult = (void*) ffGenerateTerminalJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateTerminalJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Terminal process name", "process-name"},
|
||||
{"The first argument of the command line when running the terminal", "exe"},
|
||||
{"Terminal base name of arg0", "exe-name"},
|
||||
{"Terminal pid", "pid"},
|
||||
{"Terminal pretty name", "pretty-name"},
|
||||
{"Terminal version", "version"},
|
||||
{"Terminal full exe path", "exe-path"},
|
||||
{"Terminal tty / pts used", "tty"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitTerminalOptions(FFTerminalOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_TERMINAL_MODULE_NAME,
|
||||
"Print current terminal name and version",
|
||||
ffParseTerminalCommandOptions,
|
||||
ffParseTerminalJsonObject,
|
||||
ffPrintTerminal,
|
||||
ffGenerateTerminalJsonResult,
|
||||
ffPrintTerminalHelpFormat,
|
||||
ffGenerateTerminalJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_TERMINALFONT_DISPLAY_NAME "Terminal Font"
|
||||
#define FF_TERMINALFONT_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintTerminalFont(FFTerminalFontOptions* options)
|
||||
{
|
||||
@@ -33,7 +32,7 @@ void ffPrintTerminalFont(FFTerminalFontOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_TERMINALFONT_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(terminalFont.font.pretty, "combined"),
|
||||
FF_FORMAT_ARG(terminalFont.font.name, "name"),
|
||||
FF_FORMAT_ARG(terminalFont.font.size, "size"),
|
||||
@@ -121,29 +120,25 @@ void ffGenerateTerminalFontJsonResult(FF_MAYBE_UNUSED FFTerminalOptions* options
|
||||
ffFontDestroy(&result.fallback);
|
||||
}
|
||||
|
||||
void ffPrintTerminalFontHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_TERMINALFONT_MODULE_NAME, "{1}", FF_TERMINALFONT_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Terminal font combined - combined",
|
||||
"Terminal font name - name",
|
||||
"Terminal font size - size",
|
||||
"Terminal font styles - styles",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_TERMINALFONT_MODULE_NAME,
|
||||
.description = "Print font name and size used by current terminal",
|
||||
.parseCommandOptions = (void*) ffParseTerminalFontCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseTerminalFontJsonObject,
|
||||
.printModule = (void*) ffPrintTerminalFont,
|
||||
.generateJsonResult = (void*) ffGenerateTerminalFontJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateTerminalFontJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Terminal font combined", "combined"},
|
||||
{"Terminal font name", "name"},
|
||||
{"Terminal font size", "size"},
|
||||
{"Terminal font styles", "styles"},
|
||||
})),
|
||||
};
|
||||
|
||||
void ffInitTerminalFontOptions(FFTerminalFontOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_TERMINALFONT_MODULE_NAME,
|
||||
"Print font name and size used by current terminal",
|
||||
ffParseTerminalFontCommandOptions,
|
||||
ffParseTerminalFontJsonObject,
|
||||
ffPrintTerminalFont,
|
||||
ffGenerateTerminalFontJsonResult,
|
||||
ffPrintTerminalFontHelpFormat,
|
||||
ffGenerateTerminalFontJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_TERMINALSIZE_DISPLAY_NAME "Terminal Size"
|
||||
#define FF_TERMINALSIZE_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintTerminalSize(FFTerminalSizeOptions* options)
|
||||
{
|
||||
@@ -29,7 +28,7 @@ void ffPrintTerminalSize(FFTerminalSizeOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TERMINALSIZE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_TERMINALSIZE_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TERMINALSIZE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(result.rows, "rows"),
|
||||
FF_FORMAT_ARG(result.columns, "columns"),
|
||||
FF_FORMAT_ARG(result.width, "width"),
|
||||
@@ -91,29 +90,25 @@ void ffGenerateTerminalSizeJsonResult(FF_MAYBE_UNUSED FFTerminalOptions* options
|
||||
yyjson_mut_obj_add_uint(doc, obj, "height", result.height);
|
||||
}
|
||||
|
||||
void ffPrintTerminalSizeHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_TERMINALSIZE_MODULE_NAME, "{1} columns x {2} rows ({3}px x {4}px)", FF_TERMINALSIZE_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Terminal rows - rows",
|
||||
"Terminal columns - columns",
|
||||
"Terminal width (in pixels) - width",
|
||||
"Terminal height (in pixels) - height",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_TERMINALSIZE_MODULE_NAME,
|
||||
.description = "Print current terminal size",
|
||||
.parseCommandOptions = (void*) ffParseTerminalSizeCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseTerminalSizeJsonObject,
|
||||
.printModule = (void*) ffPrintTerminalSize,
|
||||
.generateJsonResult = (void*) ffGenerateTerminalSizeJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateTerminalSizeJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Terminal rows", "rows"},
|
||||
{"Terminal columns", "columns"},
|
||||
{"Terminal width (in pixels)", "width"},
|
||||
{"Terminal height (in pixels)", "height"},
|
||||
})),
|
||||
};
|
||||
|
||||
void ffInitTerminalSizeOptions(FFTerminalSizeOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_TERMINALSIZE_MODULE_NAME,
|
||||
"Print current terminal size",
|
||||
ffParseTerminalSizeCommandOptions,
|
||||
ffParseTerminalSizeJsonObject,
|
||||
ffPrintTerminalSize,
|
||||
ffGenerateTerminalSizeJsonResult,
|
||||
ffPrintTerminalSizeHelpFormat,
|
||||
ffGenerateTerminalSizeJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
#define FF_TERMINALTHEME_DISPLAY_NAME "Terminal Theme"
|
||||
#define FF_TERMINALTHEME_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintTerminalTheme(FFTerminalThemeOptions* options)
|
||||
{
|
||||
@@ -34,7 +33,7 @@ void ffPrintTerminalTheme(FFTerminalThemeOptions* options)
|
||||
const char* bgType = result.bg.dark ? "Dark" : "Light";
|
||||
snprintf(fg, ARRAY_SIZE(fg), "#%02" PRIX16 "%02" PRIX16 "%02" PRIX16, result.fg.r, result.fg.g, result.fg.b);
|
||||
snprintf(bg, ARRAY_SIZE(bg), "#%02" PRIX16 "%02" PRIX16 "%02" PRIX16, result.bg.r, result.bg.g, result.bg.b);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TERMINALTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_TERMINALTHEME_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TERMINALTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(fg, "fg-color"),
|
||||
FF_FORMAT_ARG(fgType, "fg-type"),
|
||||
FF_FORMAT_ARG(bg, "bg-color"),
|
||||
@@ -104,29 +103,25 @@ void ffGenerateTerminalThemeJsonResult(FF_MAYBE_UNUSED FFTerminalOptions* option
|
||||
yyjson_mut_obj_add_bool(doc, bg, "dark", result.bg.dark);
|
||||
}
|
||||
|
||||
void ffPrintTerminalThemeHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_TERMINALTHEME_MODULE_NAME, "{1} (FG) {3} (BG) [{4}]", FF_TERMINALTHEME_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Terminal foreground color - fg-color",
|
||||
"Terminal foreground type (Dark / Light) - fg-type",
|
||||
"Terminal background color - bg-color",
|
||||
"Terminal background type (Dark / Light) - bg-type",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_TERMINALTHEME_MODULE_NAME,
|
||||
.description = "Print current terminal theme (foreground and background colors)",
|
||||
.parseCommandOptions = (void*) ffParseTerminalThemeCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseTerminalThemeJsonObject,
|
||||
.printModule = (void*) ffPrintTerminalTheme,
|
||||
.generateJsonResult = (void*) ffGenerateTerminalThemeJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateTerminalThemeJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Terminal foreground color", "fg-color"},
|
||||
{"Terminal foreground type (Dark / Light)", "fg-type"},
|
||||
{"Terminal background color", "bg-color"},
|
||||
{"Terminal background type (Dark / Light)", "bg-type"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitTerminalThemeOptions(FFTerminalThemeOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_TERMINALTHEME_MODULE_NAME,
|
||||
"Print current terminal theme (foreground and background colors)",
|
||||
ffParseTerminalThemeCommandOptions,
|
||||
ffParseTerminalThemeJsonObject,
|
||||
ffPrintTerminalTheme,
|
||||
ffGenerateTerminalThemeJsonResult,
|
||||
ffPrintTerminalThemeHelpFormat,
|
||||
ffGenerateTerminalThemeJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+15
-21
@@ -4,8 +4,6 @@
|
||||
#include "modules/theme/theme.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_THEME_NUM_FORMAT_ARGS 2
|
||||
|
||||
void ffPrintTheme(FFThemeOptions* options)
|
||||
{
|
||||
FFThemeResult result = {
|
||||
@@ -35,7 +33,7 @@ void ffPrintTheme(FFThemeOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_THEME_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_THEME_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_THEME_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(result.theme1, "theme1"),
|
||||
FF_FORMAT_ARG(result.theme2, "theme2"),
|
||||
}));
|
||||
@@ -102,27 +100,23 @@ void ffGenerateThemeJsonResult(FF_MAYBE_UNUSED FFThemeOptions* options, yyjson_m
|
||||
ffStrbufDestroy(&result.theme2);
|
||||
}
|
||||
|
||||
void ffPrintThemeHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_THEME_MODULE_NAME, "{1}, {2}", FF_THEME_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Theme part 1 - theme1",
|
||||
"Theme part 2 - theme2",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_THEME_MODULE_NAME,
|
||||
.description = "Print current theme of desktop environment",
|
||||
.parseCommandOptions = (void*) ffParseThemeCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseThemeJsonObject,
|
||||
.printModule = (void*) ffPrintTheme,
|
||||
.generateJsonResult = (void*) ffGenerateThemeJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateThemeJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Theme part 1", "theme1"},
|
||||
{"Theme part 2", "theme2"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitThemeOptions(FFThemeOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_THEME_MODULE_NAME,
|
||||
"Print current theme of desktop environment",
|
||||
ffParseThemeCommandOptions,
|
||||
ffParseThemeJsonObject,
|
||||
ffPrintTheme,
|
||||
ffGenerateThemeJsonResult,
|
||||
ffPrintThemeHelpFormat,
|
||||
ffGenerateThemeJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user