diff --git a/CHANGELOG.md b/CHANGELOG.md index 7657821e3..6f24f1410 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Features: * Support additional temperature formatting options (#737) * `{ "temp": { "ndigits": 1 } }` * `{ "temp": { "color": { "green": "green", "yellow": "yellow", "red": "red" } } }` +* Support specifying custom `pci.ids` path for Linux (GPU, Linux) # 2.8.5 diff --git a/CMakeLists.txt b/CMakeLists.txt index a4b16f798..7f264a168 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,6 +76,10 @@ option(ENABLE_PROPRIETARY_GPU_DRIVER_API "Enable proprietary GPU driver API (NVM option(BUILD_TESTS "Build tests" OFF) # Also create test executables option(SET_TWEAK "Add tweak to project version" ON) # This is set to off by github actions for release builds +if (LINUX) + set(CUSTOM_PCI_IDS_PATH "" CACHE STRING "Custom path to file pci.ids, defaults to `/usr/share/hwdata/pci.ids`") +endif() + #################### # Compiler options # #################### @@ -763,6 +767,11 @@ if(HAVE_WCWIDTH) target_compile_definitions(libfastfetch PRIVATE FF_HAVE_WCWIDTH) endif() +if(NOT "${CUSTOM_PCI_IDS_PATH}" STREQUAL "") + message(STATUS "Custom file path of pci.ids: ${CUSTOM_PCI_IDS_PATH}") + target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_PCI_IDS_PATH=${CUSTOM_PCI_IDS_PATH}) +endif() + function(ff_lib_enable VARNAME PKGCONFIG_NAMES CMAKE_NAME) if(NOT ENABLE_${VARNAME}) return() diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index 1c5b2f3c5..d1fb13e4f 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -9,6 +9,9 @@ #include "detection/gpu/gpu_driver_specific.h" #endif +#define FF_STR_INDIR(x) #x +#define FF_STR(x) FF_STR_INDIR(x) + #include FF_MAYBE_UNUSED static void pciDetectTemp(FFGPUResult* gpu, uint32_t deviceClass) @@ -53,6 +56,11 @@ static void pciDetectDriver(FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer static bool loadPciIds(FFstrbuf* pciids) { + #ifdef FF_CUSTOM_PCI_IDS_PATH + ffReadFileBuffer(FF_STR(FF_CUSTOM_PCI_IDS_PATH), pciids); + if (pciids->length > 0) return true; + #endif + ffReadFileBuffer(FASTFETCH_TARGET_DIR_USR "/share/hwdata/pci.ids", pciids); if (pciids->length > 0) return true;