Skip to content

Commit 111f711

Browse files
committed
GPU (Linux): Support specifying custom pci.ids path for Linux
1 parent 5147651 commit 111f711

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Features:
1010
* Support additional temperature formatting options (#737)
1111
* `{ "temp": { "ndigits": 1 } }`
1212
* `{ "temp": { "color": { "green": "green", "yellow": "yellow", "red": "red" } } }`
13+
* Support specifying custom `pci.ids` path for Linux (GPU, Linux)
1314

1415
# 2.8.5
1516

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ option(ENABLE_PROPRIETARY_GPU_DRIVER_API "Enable proprietary GPU driver API (NVM
7676
option(BUILD_TESTS "Build tests" OFF) # Also create test executables
7777
option(SET_TWEAK "Add tweak to project version" ON) # This is set to off by github actions for release builds
7878

79+
if (LINUX)
80+
set(CUSTOM_PCI_IDS_PATH "" CACHE STRING "Custom path to file pci.ids, defaults to `/usr/share/hwdata/pci.ids`")
81+
endif()
82+
7983
####################
8084
# Compiler options #
8185
####################
@@ -763,6 +767,11 @@ if(HAVE_WCWIDTH)
763767
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_WCWIDTH)
764768
endif()
765769

770+
if(NOT "${CUSTOM_PCI_IDS_PATH}" STREQUAL "")
771+
message(STATUS "Custom file path of pci.ids: ${CUSTOM_PCI_IDS_PATH}")
772+
target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_PCI_IDS_PATH=${CUSTOM_PCI_IDS_PATH})
773+
endif()
774+
766775
function(ff_lib_enable VARNAME PKGCONFIG_NAMES CMAKE_NAME)
767776
if(NOT ENABLE_${VARNAME})
768777
return()

src/detection/gpu/gpu_linux.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
#include "detection/gpu/gpu_driver_specific.h"
1010
#endif
1111

12+
#define FF_STR_INDIR(x) #x
13+
#define FF_STR(x) FF_STR_INDIR(x)
14+
1215
#include <inttypes.h>
1316

1417
FF_MAYBE_UNUSED static void pciDetectTemp(FFGPUResult* gpu, uint32_t deviceClass)
@@ -53,6 +56,11 @@ static void pciDetectDriver(FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer
5356

5457
static bool loadPciIds(FFstrbuf* pciids)
5558
{
59+
#ifdef FF_CUSTOM_PCI_IDS_PATH
60+
ffReadFileBuffer(FF_STR(FF_CUSTOM_PCI_IDS_PATH), pciids);
61+
if (pciids->length > 0) return true;
62+
#endif
63+
5664
ffReadFileBuffer(FASTFETCH_TARGET_DIR_USR "/share/hwdata/pci.ids", pciids);
5765
if (pciids->length > 0) return true;
5866

0 commit comments

Comments
 (0)