diff --git a/CMakeLists.txt b/CMakeLists.txt index 72b4acba7..73dd8cc7b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,6 +80,7 @@ option(IS_MUSL "Build with musl libc" OFF) # Used by Github Actions if (LINUX) set(CUSTOM_PCI_IDS_PATH "" CACHE STRING "Custom path to file pci.ids, defaults to `/usr/share/hwdata/pci.ids`") set(CUSTOM_AMDGPU_IDS_PATH "" CACHE STRING "Custom path to file amdgpu.ids, defaults to `/usr/share/libdrm/amdgpu.ids`") + set(CUSTOM_OS_RELEASE_PATH "" CACHE STRING "Custom path to file os-release, defaults to `/etc/os-release`") endif() #################### @@ -789,6 +790,10 @@ if(NOT "${CUSTOM_AMDGPU_IDS_PATH}" STREQUAL "") message(STATUS "Custom file path of amdgpu.ids: ${CUSTOM_AMDGPU_IDS_PATH}") target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_AMDGPU_IDS_PATH=${CUSTOM_AMDGPU_IDS_PATH}) endif() +if(NOT "${CUSTOM_OS_RELEASE_PATH}" STREQUAL "") + message(STATUS "Custom file path of os_release: ${CUSTOM_OS_RELEASE_PATH}") + target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_OS_RELEASE_PATH=${CUSTOM_OS_RELEASE_PATH}) +endif() function(ff_lib_enable VARNAME PKGCONFIG_NAMES CMAKE_NAME) if(NOT ENABLE_${VARNAME}) diff --git a/doc/json_schema.json b/doc/json_schema.json index e9ea50c26..65d80d8aa 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -294,10 +294,6 @@ "type": "string", "description": "The name of the player to use for module Media and Player. Linux only" }, - "osFile": { - "type": "string", - "description": "Set the path to the file containing OS information. Linux only" - }, "dsForceDrm": { "description": "Force display detection to use DRM. Linux only", "oneOf": [ diff --git a/src/detection/os/os_linux.c b/src/detection/os/os_linux.c index 9d0ad5185..f0fc57346 100644 --- a/src/detection/os/os_linux.c +++ b/src/detection/os/os_linux.c @@ -7,6 +7,9 @@ #include #include +#define FF_STR_INDIR(x) #x +#define FF_STR(x) FF_STR_INDIR(x) + static inline bool allRelevantValuesSet(const FFOSResult* result) { return result->id.length > 0 @@ -141,12 +144,11 @@ static void getDebianVersion(FFOSResult* result) static void detectOS(FFOSResult* os) { - if(instance.config.general.osFile.length > 0) - { - parseLsbRelease(instance.config.general.osFile.chars, os); - parseOsRelease(instance.config.general.osFile.chars, os); - return; - } + #ifdef FF_CUSTOM_OS_RELEASE_PATH + parseOsRelease(FF_STR(FF_CUSTOM_OS_RELEASE_PATH), os); + parseLsbRelease(FF_STR(FF_CUSTOM_OS_RELEASE_PATH), os); + return; + #endif if(instance.config.general.escapeBedrock && parseOsRelease(FASTFETCH_TARGET_DIR_ROOT "/bedrock" FASTFETCH_TARGET_DIR_ETC "/bedrock-release", os)) { diff --git a/src/options/general.c b/src/options/general.c index 7cec888f7..f27dce3e5 100644 --- a/src/options/general.c +++ b/src/options/general.c @@ -27,8 +27,6 @@ const char* ffOptionsParseGeneralJsonConfig(FFOptionsGeneral* options, yyjson_va options->escapeBedrock = yyjson_get_bool(val); else if (ffStrEqualsIgnCase(key, "playerName")) ffStrbufSetS(&options->playerName, yyjson_get_str(val)); - else if (ffStrEqualsIgnCase(key, "osFile")) - ffStrbufSetS(&options->osFile, yyjson_get_str(val)); else if (ffStrEqualsIgnCase(key, "dsForceDrm")) { if (yyjson_is_str(val)) @@ -79,8 +77,6 @@ bool ffOptionsParseGeneralCommandLine(FFOptionsGeneral* options, const char* key options->escapeBedrock = ffOptionParseBoolean(value); else if(ffStrEqualsIgnCase(key, "--player-name")) ffOptionParseString(key, value, &options->playerName); - else if (ffStrEqualsIgnCase(key, "--os-file")) - ffOptionParseString(key, value, &options->osFile); else if(ffStrEqualsIgnCase(key, "--ds-force-drm")) { if (ffOptionParseBoolean(value)) @@ -109,7 +105,6 @@ void ffOptionsInitGeneral(FFOptionsGeneral* options) #if defined(__linux__) || defined(__FreeBSD__) options->escapeBedrock = true; ffStrbufInit(&options->playerName); - ffStrbufInit(&options->osFile); options->dsForceDrm = FF_DS_FORCE_DRM_TYPE_FALSE; #elif defined(_WIN32) options->wmiTimeout = 5000; @@ -120,7 +115,6 @@ void ffOptionsDestroyGeneral(FF_MAYBE_UNUSED FFOptionsGeneral* options) { #if defined(__linux__) || defined(__FreeBSD__) ffStrbufDestroy(&options->playerName); - ffStrbufDestroy(&options->osFile); #endif } @@ -145,9 +139,6 @@ void ffOptionsGenerateGeneralJsonConfig(FFOptionsGeneral* options, yyjson_mut_do if (!ffStrbufEqual(&options->playerName, &defaultOptions.playerName)) yyjson_mut_obj_add_strbuf(doc, obj, "playerName", &options->playerName); - if (!ffStrbufEqual(&options->osFile, &defaultOptions.osFile)) - yyjson_mut_obj_add_strbuf(doc, obj, "osFile", &options->osFile); - if (options->dsForceDrm != defaultOptions.dsForceDrm) { switch (options->dsForceDrm) diff --git a/src/options/general.h b/src/options/general.h index 98667c2f8..0ab8ee5a7 100644 --- a/src/options/general.h +++ b/src/options/general.h @@ -17,7 +17,6 @@ typedef struct FFOptionsGeneral // Module options that cannot be put in module option structure #if defined(__linux__) || defined(__FreeBSD__) FFstrbuf playerName; - FFstrbuf osFile; bool escapeBedrock; FFDsForceDrmType dsForceDrm; #elif defined(_WIN32)