mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2025-02-20 11:43:27 +08:00
GPU: support JSON config
This commit is contained in:
parent
9addc016fb
commit
2359b7e2f4
@ -279,7 +279,7 @@ set(LIBFASTFETCH_SRC
|
||||
src/modules/de.c
|
||||
src/modules/disk.c
|
||||
src/modules/font.c
|
||||
src/modules/gpu.c
|
||||
src/modules/gpu/gpu.c
|
||||
src/modules/host/host.c
|
||||
src/modules/icons.c
|
||||
src/modules/gamepad.c
|
||||
|
@ -83,7 +83,7 @@ static void defaultConfig(FFinstance* instance)
|
||||
initModuleArg(&instance->config.terminalFont);
|
||||
ffInitCPUOptions(&instance->config.cpu);
|
||||
ffInitCPUUsageOptions(&instance->config.cpuUsage);
|
||||
initModuleArg(&instance->config.gpu);
|
||||
ffInitGPUOptions(&instance->config.gpu);
|
||||
initModuleArg(&instance->config.memory);
|
||||
initModuleArg(&instance->config.swap);
|
||||
initModuleArg(&instance->config.disk);
|
||||
@ -133,12 +133,6 @@ static void defaultConfig(FFinstance* instance)
|
||||
ffStrbufInit(&instance->config.libwlanapi);
|
||||
ffStrbufInit(&instance->config.libnm);
|
||||
|
||||
instance->config.gpuTemp = false;
|
||||
instance->config.gpuForceVulkan = false;
|
||||
|
||||
instance->config.gpuHideIntegrated = false;
|
||||
instance->config.gpuHideDiscrete = false;
|
||||
|
||||
instance->config.shellVersion = true;
|
||||
instance->config.terminalVersion = true;
|
||||
|
||||
@ -319,7 +313,7 @@ static void destroyConfig(FFinstance* instance)
|
||||
destroyModuleArg(&instance->config.terminalFont);
|
||||
ffDestroyCPUOptions(&instance->config.cpu);
|
||||
ffDestroyCPUUsageOptions(&instance->config.cpuUsage);
|
||||
destroyModuleArg(&instance->config.gpu);
|
||||
ffDestroyGPUOptions(&instance->config.gpu);
|
||||
destroyModuleArg(&instance->config.memory);
|
||||
destroyModuleArg(&instance->config.swap);
|
||||
destroyModuleArg(&instance->config.disk);
|
||||
|
@ -36,7 +36,7 @@ const FFlist* ffDetectGPU(const FFinstance* instance)
|
||||
{
|
||||
FF_DETECTION_INTERNAL_GUARD(FFlist,
|
||||
ffListInit(&result, sizeof(FFGPUResult));
|
||||
if(instance->config.gpuForceVulkan || ffDetectGPUImpl(&result, instance) != NULL)
|
||||
if(instance->config.gpu.forceVulkan || ffDetectGPUImpl(&result, instance) != NULL)
|
||||
{
|
||||
const FFVulkanResult* vulkan = ffDetectVulkan(instance);
|
||||
result = vulkan->gpus;
|
||||
|
@ -14,13 +14,6 @@ extern const char* FF_GPU_VENDOR_NAME_AMD;
|
||||
extern const char* FF_GPU_VENDOR_NAME_INTEL;
|
||||
extern const char* FF_GPU_VENDOR_NAME_NVIDIA;
|
||||
|
||||
typedef enum FFGpuType
|
||||
{
|
||||
FF_GPU_TYPE_UNKNOWN,
|
||||
FF_GPU_TYPE_INTEGRATED,
|
||||
FF_GPU_TYPE_DISCRETE,
|
||||
} FFGpuType;
|
||||
|
||||
typedef struct FFGPUMemory
|
||||
{
|
||||
uint64_t total;
|
||||
@ -29,7 +22,7 @@ typedef struct FFGPUMemory
|
||||
|
||||
typedef struct FFGPUResult
|
||||
{
|
||||
FFGpuType type;
|
||||
FFGPUType type;
|
||||
FFstrbuf vendor;
|
||||
FFstrbuf name;
|
||||
FFstrbuf driver;
|
||||
|
@ -99,7 +99,7 @@ const char* ffDetectGPUImpl(FFlist* gpus, const FFinstance* instance)
|
||||
if(ffCfDictGetInt(properties, CFSTR("gpu-core-count"), &gpu->coreCount))
|
||||
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
|
||||
|
||||
if(instance->config.gpuTemp)
|
||||
if(instance->config.gpu.temp)
|
||||
gpu->temperature = detectGpuTemp(&gpu->name);
|
||||
else
|
||||
gpu->temperature = FF_GPU_TEMP_UNSET;
|
||||
|
@ -216,7 +216,7 @@ static void pciHandleDevice(const FFinstance* instance, FFlist* results, PCIData
|
||||
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
|
||||
|
||||
gpu->temperature = FF_GPU_TEMP_UNSET;
|
||||
if(instance->config.gpuTemp)
|
||||
if(instance->config.gpu.temp)
|
||||
pciDetectTemperatur(gpu, device);
|
||||
}
|
||||
|
||||
|
@ -1004,7 +1004,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
else if(optionParseModuleArgs(key, value, "terminal-font", &instance->config.terminalFont)) {}
|
||||
else if(ffParseCPUCommandOptions(&instance->config.cpu, key, value)) {}
|
||||
else if(ffParseCPUUsageCommandOptions(&instance->config.cpuUsage, key, value)) {}
|
||||
else if(optionParseModuleArgs(key, value, "gpu", &instance->config.gpu)) {}
|
||||
else if(ffParseGPUCommandOptions(&instance->config.gpu, key, value)) {}
|
||||
else if(optionParseModuleArgs(key, value, "memory", &instance->config.memory)) {}
|
||||
else if(optionParseModuleArgs(key, value, "swap", &instance->config.swap)) {}
|
||||
else if(optionParseModuleArgs(key, value, "disk", &instance->config.disk)) {}
|
||||
@ -1091,14 +1091,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
//Module options//
|
||||
//////////////////
|
||||
|
||||
else if(strcasecmp(key, "--gpu-temp") == 0)
|
||||
instance->config.gpuTemp = optionParseBoolean(value);
|
||||
else if(strcasecmp(key, "--gpu-force-vulkan") == 0)
|
||||
instance->config.gpuForceVulkan = optionParseBoolean(value);
|
||||
else if(strcasecmp(key, "--gpu-hide-integrated") == 0)
|
||||
instance->config.gpuHideIntegrated = optionParseBoolean(value);
|
||||
else if(strcasecmp(key, "--gpu-hide-discrete") == 0)
|
||||
instance->config.gpuHideDiscrete = optionParseBoolean(value);
|
||||
else if(strcasecmp(key, "--shell-version") == 0)
|
||||
instance->config.shellVersion = optionParseBoolean(value);
|
||||
else if(strcasecmp(key, "--terminal-version") == 0)
|
||||
@ -1266,8 +1258,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line)
|
||||
ffPrintCPUUsage(instance, &instance->config.cpuUsage);
|
||||
else if(strcasecmp(line, FF_CUSTOM_MODULE_NAME) == 0)
|
||||
ffPrintCustom(instance, &instance->config.custom);
|
||||
else if(strcasecmp(line, "gpu") == 0)
|
||||
ffPrintGPU(instance);
|
||||
else if(strcasecmp(line, FF_GPU_MODULE_NAME) == 0)
|
||||
ffPrintGPU(instance, &instance->config.gpu);
|
||||
else if(strcasecmp(line, "memory") == 0)
|
||||
ffPrintMemory(instance);
|
||||
else if(strcasecmp(line, "swap") == 0)
|
||||
|
@ -119,7 +119,7 @@ typedef struct FFconfig
|
||||
FFCPUOptions cpu;
|
||||
FFCPUUsageOptions cpuUsage;
|
||||
FFCustomOptions custom;
|
||||
FFModuleArgs gpu;
|
||||
FFGPUOptions gpu;
|
||||
FFModuleArgs memory;
|
||||
FFModuleArgs swap;
|
||||
FFModuleArgs disk;
|
||||
@ -167,12 +167,6 @@ typedef struct FFconfig
|
||||
FFstrbuf libwlanapi;
|
||||
FFstrbuf libnm;
|
||||
|
||||
bool gpuTemp;
|
||||
bool gpuForceVulkan;
|
||||
|
||||
bool gpuHideIntegrated;
|
||||
bool gpuHideDiscrete;
|
||||
|
||||
bool shellVersion;
|
||||
bool terminalVersion;
|
||||
|
||||
@ -262,7 +256,6 @@ void ffPrintWallpaper(FFinstance* instance);
|
||||
void ffPrintFont(FFinstance* instance);
|
||||
void ffPrintTerminal(FFinstance* instance);
|
||||
void ffPrintTerminalFont(FFinstance* instance);
|
||||
void ffPrintGPU(FFinstance* instance);
|
||||
void ffPrintMemory(FFinstance* instance);
|
||||
void ffPrintSwap(FFinstance* instance);
|
||||
void ffPrintDisk(FFinstance* instance);
|
||||
|
@ -44,7 +44,7 @@ int main(int argc, char** argv)
|
||||
ffPrintTerminal(&instance);
|
||||
ffPrintTerminalFont(&instance);
|
||||
ffPrintCPU(&instance, &instance.config.cpu);
|
||||
ffPrintGPU(&instance);
|
||||
ffPrintGPU(&instance, &instance.config.gpu);
|
||||
ffPrintMemory(&instance);
|
||||
//ffPrintSwap(&instance);
|
||||
ffPrintDisk(&instance);
|
||||
|
@ -1,104 +0,0 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/bar.h"
|
||||
#include "common/parsing.h"
|
||||
#include "common/printing.h"
|
||||
#include "detection/host/host.h"
|
||||
#include "detection/gpu/gpu.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FF_GPU_MODULE_NAME "GPU"
|
||||
#define FF_GPU_NUM_FORMAT_ARGS 6
|
||||
|
||||
static void printGPUResult(FFinstance* instance, uint8_t index, const FFGPUResult* gpu)
|
||||
{
|
||||
if(instance->config.gpu.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_GPU_MODULE_NAME, index, &instance->config.gpu.key);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY output;
|
||||
ffStrbufInitA(&output, gpu->vendor.length + 1 + gpu->name.length);
|
||||
|
||||
if(gpu->vendor.length > 0 && !ffStrbufStartsWith(&gpu->name, &gpu->vendor))
|
||||
{
|
||||
ffStrbufAppend(&output, &gpu->vendor);
|
||||
ffStrbufAppendC(&output, ' ');
|
||||
}
|
||||
|
||||
ffStrbufAppend(&output, &gpu->name);
|
||||
|
||||
if(gpu->coreCount != FF_GPU_CORE_COUNT_UNSET)
|
||||
ffStrbufAppendF(&output, " (%d)", gpu->coreCount);
|
||||
|
||||
if(gpu->temperature == gpu->temperature) //FF_GPU_TEMP_UNSET
|
||||
ffStrbufAppendF(&output, " - %.1f°C", gpu->temperature);
|
||||
|
||||
if(gpu->dedicated.total != FF_GPU_VMEM_SIZE_UNSET && gpu->dedicated.total != 0)
|
||||
{
|
||||
ffStrbufAppendS(&output, " (");
|
||||
|
||||
if(gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET)
|
||||
{
|
||||
ffParseSize(gpu->dedicated.used, instance->config.binaryPrefixType, &output);
|
||||
ffStrbufAppendS(&output, " / ");
|
||||
}
|
||||
ffParseSize(gpu->dedicated.total, instance->config.binaryPrefixType, &output);
|
||||
if(gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET)
|
||||
{
|
||||
ffStrbufAppendS(&output, ", ");
|
||||
ffAppendPercentNum(instance, &output, (uint8_t) (gpu->dedicated.used * 100 / gpu->dedicated.total), 50, 80, false);
|
||||
}
|
||||
ffStrbufAppendC(&output, ')');
|
||||
}
|
||||
|
||||
ffStrbufPutTo(&output, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char* type;
|
||||
if(gpu->type == FF_GPU_TYPE_INTEGRATED)
|
||||
type = "Integrated";
|
||||
else if(gpu->type == FF_GPU_TYPE_DISCRETE)
|
||||
type = "Discrete";
|
||||
else
|
||||
type = "Unknown";
|
||||
|
||||
ffPrintFormat(instance, FF_GPU_MODULE_NAME, index, &instance->config.gpu, FF_GPU_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->vendor},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->driver},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &gpu->temperature},
|
||||
{FF_FORMAT_ARG_TYPE_INT, &gpu->coreCount},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, type},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintGPU(FFinstance* instance)
|
||||
{
|
||||
const FFlist* gpus = ffDetectGPU(instance);
|
||||
|
||||
FFlist selectedGpus;
|
||||
ffListInitA(&selectedGpus, sizeof(const FFGPUResult*), gpus->length);
|
||||
|
||||
for(uint32_t i = 0; i < gpus->length; i++)
|
||||
{
|
||||
const FFGPUResult* gpu = ffListGet(gpus, i);
|
||||
|
||||
if(gpu->type == FF_GPU_TYPE_INTEGRATED && instance->config.gpuHideIntegrated)
|
||||
continue;
|
||||
|
||||
if(gpu->type == FF_GPU_TYPE_DISCRETE && instance->config.gpuHideDiscrete)
|
||||
continue;
|
||||
|
||||
* (const FFGPUResult**) ffListAdd(&selectedGpus) = gpu;
|
||||
}
|
||||
|
||||
for(uint32_t i = 0; i < selectedGpus.length; i++)
|
||||
printGPUResult(instance, selectedGpus.length == 1 ? 0 : (uint8_t) (i + 1), * (const FFGPUResult**) ffListGet(&selectedGpus, i));
|
||||
|
||||
if(selectedGpus.length == 0)
|
||||
ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &instance->config.gpu, "No GPUs found");
|
||||
|
||||
ffListDestroy(&selectedGpus);
|
||||
}
|
196
src/modules/gpu/gpu.c
Normal file
196
src/modules/gpu/gpu.c
Normal file
@ -0,0 +1,196 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/bar.h"
|
||||
#include "common/parsing.h"
|
||||
#include "common/printing.h"
|
||||
#include "detection/host/host.h"
|
||||
#include "detection/gpu/gpu.h"
|
||||
#include "modules/gpu/gpu.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FF_GPU_NUM_FORMAT_ARGS 6
|
||||
|
||||
static void printGPUResult(FFinstance* instance, FFGPUOptions* options, uint8_t index, const FFGPUResult* gpu)
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_GPU_MODULE_NAME, index, &options->moduleArgs.key);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY output;
|
||||
ffStrbufInitA(&output, gpu->vendor.length + 1 + gpu->name.length);
|
||||
|
||||
if(gpu->vendor.length > 0 && !ffStrbufStartsWith(&gpu->name, &gpu->vendor))
|
||||
{
|
||||
ffStrbufAppend(&output, &gpu->vendor);
|
||||
ffStrbufAppendC(&output, ' ');
|
||||
}
|
||||
|
||||
ffStrbufAppend(&output, &gpu->name);
|
||||
|
||||
if(gpu->coreCount != FF_GPU_CORE_COUNT_UNSET)
|
||||
ffStrbufAppendF(&output, " (%d)", gpu->coreCount);
|
||||
|
||||
if(gpu->temperature == gpu->temperature) //FF_GPU_TEMP_UNSET
|
||||
ffStrbufAppendF(&output, " - %.1f°C", gpu->temperature);
|
||||
|
||||
if(gpu->dedicated.total != FF_GPU_VMEM_SIZE_UNSET && gpu->dedicated.total != 0)
|
||||
{
|
||||
ffStrbufAppendS(&output, " (");
|
||||
|
||||
if(gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET)
|
||||
{
|
||||
ffParseSize(gpu->dedicated.used, instance->config.binaryPrefixType, &output);
|
||||
ffStrbufAppendS(&output, " / ");
|
||||
}
|
||||
ffParseSize(gpu->dedicated.total, instance->config.binaryPrefixType, &output);
|
||||
if(gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET)
|
||||
{
|
||||
ffStrbufAppendS(&output, ", ");
|
||||
ffAppendPercentNum(instance, &output, (uint8_t) (gpu->dedicated.used * 100 / gpu->dedicated.total), 50, 80, false);
|
||||
}
|
||||
ffStrbufAppendC(&output, ')');
|
||||
}
|
||||
|
||||
ffStrbufPutTo(&output, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char* type;
|
||||
if(gpu->type == FF_GPU_TYPE_INTEGRATED)
|
||||
type = "Integrated";
|
||||
else if(gpu->type == FF_GPU_TYPE_DISCRETE)
|
||||
type = "Discrete";
|
||||
else
|
||||
type = "Unknown";
|
||||
|
||||
ffPrintFormat(instance, FF_GPU_MODULE_NAME, index, &options->moduleArgs, FF_GPU_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->vendor},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->driver},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &gpu->temperature},
|
||||
{FF_FORMAT_ARG_TYPE_INT, &gpu->coreCount},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, type},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintGPU(FFinstance* instance, FFGPUOptions* options)
|
||||
{
|
||||
const FFlist* gpus = ffDetectGPU(instance);
|
||||
|
||||
FF_LIST_AUTO_DESTROY selectedGPUs;
|
||||
ffListInitA(&selectedGPUs, sizeof(const FFGPUResult*), gpus->length);
|
||||
|
||||
FF_LIST_FOR_EACH(FFGPUResult, gpu, *gpus)
|
||||
{
|
||||
if(gpu->type == FF_GPU_TYPE_INTEGRATED && options->hideType == FF_GPU_TYPE_INTEGRATED)
|
||||
continue;
|
||||
|
||||
if(gpu->type == FF_GPU_TYPE_DISCRETE && options->hideType == FF_GPU_TYPE_DISCRETE)
|
||||
continue;
|
||||
|
||||
* (const FFGPUResult**) ffListAdd(&selectedGPUs) = gpu;
|
||||
}
|
||||
|
||||
for(uint32_t i = 0; i < selectedGPUs.length; i++)
|
||||
printGPUResult(instance, options, selectedGPUs.length == 1 ? 0 : (uint8_t) (i + 1), * (const FFGPUResult**) ffListGet(&selectedGPUs, i));
|
||||
|
||||
if(selectedGPUs.length == 0)
|
||||
ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &options->moduleArgs, "No GPUs found");
|
||||
}
|
||||
|
||||
void ffInitGPUOptions(FFGPUOptions* options)
|
||||
{
|
||||
options->moduleName = FF_GPU_MODULE_NAME;
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
|
||||
options->forceVulkan = false;
|
||||
options->temp = false;
|
||||
options->hideType = FF_GPU_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
bool ffParseGPUCommandOptions(FFGPUOptions* options, const char* key, const char* value)
|
||||
{
|
||||
const char* subKey = ffOptionTestPrefix(key, FF_GPU_MODULE_NAME);
|
||||
if (!subKey) return false;
|
||||
if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs))
|
||||
return true;
|
||||
|
||||
if (strcasecmp(subKey, "force-vulkan") == 0)
|
||||
{
|
||||
options->forceVulkan = ffOptionParseBoolean(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcasecmp(subKey, "temp") == 0)
|
||||
{
|
||||
options->temp = ffOptionParseBoolean(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcasecmp(subKey, "hide-type") == 0)
|
||||
{
|
||||
options->hideType = (FFGPUType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) {
|
||||
{ "none", FF_GPU_TYPE_UNKNOWN },
|
||||
{ "intergrated", FF_GPU_TYPE_INTEGRATED },
|
||||
{ "discrete", FF_GPU_TYPE_DISCRETE },
|
||||
{},
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ffDestroyGPUOptions(FFGPUOptions* options)
|
||||
{
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseGPUJsonObject(FFinstance* instance, json_object* module)
|
||||
{
|
||||
FFGPUOptions __attribute__((__cleanup__(ffDestroyGPUOptions))) options;
|
||||
ffInitGPUOptions(&options);
|
||||
|
||||
if (module)
|
||||
{
|
||||
json_object_object_foreach(module, key, val)
|
||||
{
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
if (strcasecmp(key, "temp") == 0)
|
||||
{
|
||||
options.temp = (bool) json_object_get_boolean(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcasecmp(key, "forceVulkan") == 0)
|
||||
{
|
||||
options.forceVulkan = (bool) json_object_get_boolean(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcasecmp(key, "hideType") == 0)
|
||||
{
|
||||
int value;
|
||||
const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) {
|
||||
{ "none", FF_GPU_TYPE_UNKNOWN },
|
||||
{ "intergrated", FF_GPU_TYPE_INTEGRATED },
|
||||
{ "discrete", FF_GPU_TYPE_DISCRETE },
|
||||
{},
|
||||
});
|
||||
if (error)
|
||||
ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error);
|
||||
else
|
||||
options.hideType = (FFGPUType) value;
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintGPU(instance, &options);
|
||||
}
|
||||
#endif
|
13
src/modules/gpu/gpu.h
Normal file
13
src/modules/gpu/gpu.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#define FF_GPU_MODULE_NAME "GPU"
|
||||
|
||||
void ffPrintGPU(FFinstance* instance, FFGPUOptions* options);
|
||||
void ffInitGPUOptions(FFGPUOptions* options);
|
||||
bool ffParseGPUCommandOptions(FFGPUOptions* options, const char* key, const char* value);
|
||||
void ffDestroyGPUOptions(FFGPUOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseGPUJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
22
src/modules/gpu/option.h
Normal file
22
src/modules/gpu/option.h
Normal file
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
// This file will be included in "fastfetch.h", do NOT put unnecessary things here
|
||||
|
||||
#include "common/option.h"
|
||||
|
||||
typedef enum FFGPUType
|
||||
{
|
||||
FF_GPU_TYPE_UNKNOWN,
|
||||
FF_GPU_TYPE_INTEGRATED,
|
||||
FF_GPU_TYPE_DISCRETE,
|
||||
} FFGPUType;
|
||||
|
||||
typedef struct FFGPUOptions
|
||||
{
|
||||
const char* moduleName;
|
||||
FFModuleArgs moduleArgs;
|
||||
|
||||
FFGPUType hideType;
|
||||
bool temp;
|
||||
bool forceVulkan;
|
||||
} FFGPUOptions;
|
@ -55,6 +55,12 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o
|
||||
false;
|
||||
}
|
||||
|
||||
case 'G': {
|
||||
return
|
||||
tryModule(instance, type, module, FF_GPU_MODULE_NAME, ffParseGPUJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
case 'H': {
|
||||
return
|
||||
tryModule(instance, type, module, FF_HOST_MODULE_NAME, ffParseHostJsonObject) ||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "modules/custom/custom.h"
|
||||
#include "modules/datetime/datetime.h"
|
||||
#include "modules/display/display.h"
|
||||
#include "modules/gpu/gpu.h"
|
||||
#include "modules/host/host.h"
|
||||
#include "modules/kernel/kernel.h"
|
||||
#include "modules/separator/separator.h"
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "modules/datetime/option.h"
|
||||
#include "modules/display/option.h"
|
||||
#include "modules/host/option.h"
|
||||
#include "modules/gpu/option.h"
|
||||
#include "modules/kernel/option.h"
|
||||
#include "modules/os/option.h"
|
||||
#include "modules/separator/option.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user