mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
@@ -14,6 +14,8 @@ Features:
|
||||
* Add `Brightness` module support
|
||||
* Add `Battery` module support for FreeBSD
|
||||
* Add `--disk-show-unknown` option for Disk module
|
||||
* Add `--gpu-hide-integrated` option (#379)
|
||||
* Add `--gpu-hide-discrete` option (#379)
|
||||
|
||||
Logos:
|
||||
* Raspbian (@IamNoRobot, #373)
|
||||
|
||||
@@ -191,6 +191,8 @@ __fastfetch_completion()
|
||||
"--escape-bedrock"
|
||||
"--disk-show-removable"
|
||||
"--disk-show-hidden"
|
||||
"--gpu-hide-integrated"
|
||||
"--gpu-hide-discrete"
|
||||
)
|
||||
|
||||
local FF_OPTIONS_STRING=(
|
||||
|
||||
@@ -315,6 +315,9 @@ static void defaultConfig(FFinstance* instance)
|
||||
instance->config.gpuTemp = false;
|
||||
instance->config.batteryTemp = false;
|
||||
|
||||
instance->config.gpuHideIntegrated = false;
|
||||
instance->config.gpuHideDiscrete = false;
|
||||
|
||||
instance->config.titleFQDN = false;
|
||||
|
||||
ffStrbufInitA(&instance->config.diskFolders, 0);
|
||||
|
||||
@@ -212,6 +212,13 @@
|
||||
# Default is auto.
|
||||
#--gl auto
|
||||
|
||||
# GPU hide options
|
||||
# Sets weather to hide certain gpu types
|
||||
# Must be either true or false
|
||||
# Default is false.
|
||||
#--gpu-hide-integrated
|
||||
#--gpu-hide-discrete
|
||||
|
||||
# Disk option
|
||||
# Sets if removable volume should be printed
|
||||
# Must be either true or false
|
||||
|
||||
@@ -110,6 +110,8 @@ Module specific options:
|
||||
--battery-dir <folder>: The directory where the battery folders are. Standard: /sys/class/power_supply/
|
||||
--cpu-temp <?value>: Detect and display CPU temperature if supported. Default is false
|
||||
--gpu-temp <?value>: Detect and display GPU temperature if supported. Default is false
|
||||
--gpu-hide-integrated <?value>: Hide integrated GPU if supported. Default is false
|
||||
--gpu-hide-discrete <?value>: Hide discrete GPU if supported. Default is false
|
||||
--battery-temp <?value>: Detect and display Battery temperature if supported. Default is false
|
||||
--localip-show-ipv4 <?value>: Show IPv4 addresses in local ip module. Default is true
|
||||
--localip-show-ipv6 <?value>: Show IPv6 addresses in local ip module. Default is false
|
||||
|
||||
@@ -12,8 +12,16 @@
|
||||
#define FF_GPU_VENDOR_NAME_INTEL "Intel"
|
||||
#define FF_GPU_VENDOR_NAME_NVIDIA "NVIDIA"
|
||||
|
||||
typedef enum FFGpuType
|
||||
{
|
||||
FF_GPU_TYPE_INTEGRATED,
|
||||
FF_GPU_TYPE_DISCRETE,
|
||||
FF_GPU_TYPE_UNKNOWN
|
||||
} FFGpuType;
|
||||
|
||||
typedef struct FFGPUResult
|
||||
{
|
||||
FFGpuType type;
|
||||
FFstrbuf vendor;
|
||||
FFstrbuf name;
|
||||
FFstrbuf driver;
|
||||
|
||||
@@ -59,6 +59,8 @@ const char* ffDetectGPUImpl(FFlist* gpus, const FFinstance* instance)
|
||||
|
||||
FFGPUResult* gpu = ffListAdd(gpus);
|
||||
|
||||
gpu->type = FF_GPU_TYPE_UNKNOWN;
|
||||
|
||||
ffStrbufInitA(&gpu->vendor, 0);
|
||||
|
||||
ffStrbufInit(&gpu->driver);
|
||||
|
||||
@@ -61,7 +61,7 @@ static void pciDetectVendorName(FFGPUResult* gpu, PCIData* pci, struct pci_dev*
|
||||
static void drmDetectDeviceName(const FFinstance* instance, FFGPUResult* gpu, PCIData* pci, struct pci_dev* device)
|
||||
{
|
||||
u8 revId;
|
||||
bool revIdSet = false;;
|
||||
bool revIdSet = false;
|
||||
|
||||
#if PCI_LIB_VERSION >= 0x030800
|
||||
revIdSet = pci->ffpci_fill_info(device, PCI_FILL_CLASS_EXT) & PCI_FILL_CLASS_EXT;
|
||||
@@ -167,6 +167,24 @@ static void pciDetectTemperatur(const FFinstance* instance, FFGPUResult* gpu, st
|
||||
}
|
||||
}
|
||||
|
||||
static void detectType(FFGPUResult* gpu, const PCIData* pci, struct pci_dev* device)
|
||||
{
|
||||
//There is no straightforward way to detect the type of a GPU.
|
||||
//The approach taken here is to look at the memory sizes of the device.
|
||||
//Since integrated GPUs usually use the system ram, they don't have expansive ROMs
|
||||
|
||||
if(!(pci->ffpci_fill_info(device, PCI_FILL_SIZES) & PCI_FILL_SIZES))
|
||||
{
|
||||
gpu->type = FF_GPU_TYPE_UNKNOWN;
|
||||
return;
|
||||
}
|
||||
|
||||
if(device->rom_size > 0)
|
||||
gpu->type = FF_GPU_TYPE_DISCRETE;
|
||||
else
|
||||
gpu->type = FF_GPU_TYPE_INTEGRATED;
|
||||
}
|
||||
|
||||
static void pciHandleDevice(const FFinstance* instance, FFlist* results, PCIData* pci, struct pci_dev* device)
|
||||
{
|
||||
pci->ffpci_fill_info(device, PCI_FILL_CLASS);
|
||||
@@ -175,7 +193,9 @@ static void pciHandleDevice(const FFinstance* instance, FFlist* results, PCIData
|
||||
pci->ffpci_lookup_name(pci->access, class, sizeof(class) - 1, PCI_LOOKUP_CLASS, device->device_class);
|
||||
|
||||
if(
|
||||
//https://pci-ids.ucw.cz/read/PD/03
|
||||
strcasecmp("VGA compatible controller", class) != 0 &&
|
||||
strcasecmp("XGA compatible controller", class) != 0 &&
|
||||
strcasecmp("3D controller", class) != 0 &&
|
||||
strcasecmp("Display controller", class) != 0
|
||||
) return;
|
||||
@@ -193,6 +213,8 @@ static void pciHandleDevice(const FFinstance* instance, FFlist* results, PCIData
|
||||
ffStrbufInit(&gpu->driver);
|
||||
pciDetectDriverName(gpu, pci, device);
|
||||
|
||||
detectType(gpu, pci, device);
|
||||
|
||||
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
|
||||
|
||||
gpu->temperature = FF_GPU_TEMP_UNSET;
|
||||
|
||||
@@ -26,6 +26,8 @@ static const char* detectWithDxgi(FFlist* gpus)
|
||||
|
||||
FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus);
|
||||
|
||||
gpu->type = FF_GPU_TYPE_UNKNOWN;
|
||||
|
||||
if(wmemchr((const wchar_t[]) {0x1002, 0x1022}, (wchar_t)desc.VendorId, 2))
|
||||
ffStrbufInitS(&gpu->vendor, FF_GPU_VENDOR_NAME_AMD);
|
||||
else if(wmemchr((const wchar_t[]) {0x03e7, 0x8086, 0x8087}, (wchar_t)desc.VendorId, 3))
|
||||
@@ -65,6 +67,8 @@ static const char* detectWithWmi(FFlist* gpus)
|
||||
{
|
||||
FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus);
|
||||
|
||||
gpu->type = FF_GPU_TYPE_UNKNOWN;
|
||||
|
||||
ffStrbufInit(&gpu->vendor);
|
||||
record.getString(L"AdapterCompatibility", &gpu->vendor);
|
||||
if(ffStrbufStartsWithS(&gpu->vendor, "Intel "))
|
||||
|
||||
@@ -190,6 +190,11 @@ static const char* detectVulkan(const FFinstance* instance, FFVulkanResult* resu
|
||||
ffStrbufInit(&gpu->name);
|
||||
ffStrbufAppendS(&gpu->name, physicalDeviceProperties.properties.deviceName);
|
||||
|
||||
if(physicalDeviceProperties.properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU)
|
||||
gpu->type = FF_GPU_TYPE_INTEGRATED;
|
||||
else
|
||||
gpu->type = FF_GPU_TYPE_DISCRETE;
|
||||
|
||||
//No way to detect those using vulkan
|
||||
ffStrbufInit(&gpu->vendor);
|
||||
ffStrbufInit(&gpu->driver);
|
||||
|
||||
+7
-2
@@ -288,12 +288,13 @@ static inline void printCommandHelp(const char* command)
|
||||
}
|
||||
else if(strcasecmp(command, "gpu-format") == 0)
|
||||
{
|
||||
constructAndPrintCommandHelpFormat("gpu", "{} {}", 5,
|
||||
constructAndPrintCommandHelpFormat("gpu", "{} {}", 6,
|
||||
"GPU vendor",
|
||||
"GPU name",
|
||||
"GPU driver",
|
||||
"GPU temperature",
|
||||
"GPU core count"
|
||||
"GPU core count",
|
||||
"GPU type"
|
||||
);
|
||||
}
|
||||
else if(strcasecmp(command, "memory-format") == 0)
|
||||
@@ -1246,6 +1247,10 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
instance->config.gpuTemp = optionParseBoolean(value);
|
||||
else if(strcasecmp(key, "--battery-temp") == 0)
|
||||
instance->config.batteryTemp = 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, "--title-fqdn") == 0)
|
||||
instance->config.titleFQDN = optionParseBoolean(value);
|
||||
else if(strcasecmp(key, "--disk-folders") == 0)
|
||||
|
||||
@@ -175,6 +175,9 @@ typedef struct FFconfig
|
||||
bool gpuTemp;
|
||||
bool batteryTemp;
|
||||
|
||||
bool gpuHideIntegrated;
|
||||
bool gpuHideDiscrete;
|
||||
|
||||
bool titleFQDN;
|
||||
|
||||
FFstrbuf diskFolders;
|
||||
|
||||
+34
-8
@@ -6,13 +6,13 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FF_GPU_MODULE_NAME "GPU"
|
||||
#define FF_GPU_NUM_FORMAT_ARGS 5
|
||||
#define FF_GPU_NUM_FORMAT_ARGS 6
|
||||
|
||||
static void printGPUResult(FFinstance* instance, uint8_t index, FFGPUResult* gpu)
|
||||
static void printGPUResult(FFinstance* instance, uint8_t index, const FFGPUResult* gpu)
|
||||
{
|
||||
if(instance->config.gpu.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_GPU_MODULE_NAME, 0, &instance->config.gpu.key);
|
||||
ffPrintLogoAndKey(instance, FF_GPU_MODULE_NAME, index, &instance->config.gpu.key);
|
||||
|
||||
FFstrbuf output;
|
||||
ffStrbufInitA(&output, gpu->vendor.length + 1 + gpu->name.length);
|
||||
@@ -37,13 +37,24 @@ static void printGPUResult(FFinstance* instance, uint8_t index, FFGPUResult* gpu
|
||||
}
|
||||
else
|
||||
{
|
||||
FFstrbuf type;
|
||||
if(gpu->type == FF_GPU_TYPE_INTEGRATED)
|
||||
ffStrbufInitS(&type, "Integrated");
|
||||
else if(gpu->type == FF_GPU_TYPE_DISCRETE)
|
||||
ffStrbufInitS(&type, "Discrete");
|
||||
else
|
||||
ffStrbufInitS(&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_STRBUF, &type},
|
||||
});
|
||||
|
||||
ffStrbufDestroy(&type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,12 +62,27 @@ void ffPrintGPU(FFinstance* instance)
|
||||
{
|
||||
const FFlist* gpus = ffDetectGPU(instance);
|
||||
|
||||
if(gpus->length == 0)
|
||||
FFlist selectedGpus;
|
||||
ffListInitA(&selectedGpus, sizeof(const FFGPUResult*), gpus->length);
|
||||
|
||||
for(uint32_t i = 0; i < gpus->length; i++)
|
||||
{
|
||||
ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &instance->config.gpu, "No GPUs found");
|
||||
return;
|
||||
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(uint8_t i = 0; i < (uint8_t) gpus->length; i++)
|
||||
printGPUResult(instance, gpus->length == 1 ? 0 : (uint8_t) (i + 1), ffListGet(gpus, i));
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user