diff --git a/src/fastfetch.c b/src/fastfetch.c index 3c8245abe..32cebc613 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -472,9 +472,22 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val if (parseJsoncFile(value)) return; + FF_STRBUF_AUTO_DESTROY absolutePath = ffStrbufCreateA(128); + + //Try to load as a relative path with the directory of fastfetch binary + if (instance.state.platform.exePath.length) + { + ffStrbufSet(&absolutePath, &instance.state.platform.exePath); + ffStrbufSubstrBeforeLastC(&absolutePath, '/'); + ffStrbufAppendS(&absolutePath, "/"); + ffStrbufAppendS(&absolutePath, value); + + if (parseJsoncFile(absolutePath.chars)) return; + ffStrbufClear(&absolutePath); + } + //Try to load as a relative path - FF_STRBUF_AUTO_DESTROY absolutePath = ffStrbufCreateA(128); FF_LIST_FOR_EACH(FFstrbuf, path, instance.state.platform.dataDirs) { //We need to copy it, because if a config file loads a config file, the value of path must be unchanged @@ -492,23 +505,6 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val if (success) return; } - { - //Try exe path - ffStrbufSet(&absolutePath, &instance.state.platform.exePath); - ffStrbufSubstrBeforeLastC(&absolutePath, '/'); - ffStrbufAppendS(&absolutePath, "/presets/"); - ffStrbufAppendS(&absolutePath, value); - - bool success = parseJsoncFile(absolutePath.chars); - if (!success) - { - ffStrbufAppendS(&absolutePath, ".jsonc"); - success = parseJsoncFile(absolutePath.chars); - } - - if (success) return; - } - //File not found fprintf(stderr, "Error: couldn't find config: %s\n", value); diff --git a/src/util/platform/FFPlatform_unix.c b/src/util/platform/FFPlatform_unix.c index fbf59d85f..a6d5321d6 100644 --- a/src/util/platform/FFPlatform_unix.c +++ b/src/util/platform/FFPlatform_unix.c @@ -172,6 +172,14 @@ static void getDataDirs(FFPlatform* platform) #endif ffPlatformPathAddAbsolute(&platform->dataDirs, FASTFETCH_TARGET_DIR_USR "/local/share/"); ffPlatformPathAddAbsolute(&platform->dataDirs, FASTFETCH_TARGET_DIR_USR "/share/"); + + if (platform->exePath.length > 0) + { + // Add ${currentExePath} + FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateCopy(&platform->exePath); + ffStrbufSubstrBeforeLastC(&path, '/'); + ffPlatformPathAddAbsolute(&platform->dataDirs, path.chars); + } } static void getUserName(FFPlatform* platform, const struct passwd* pwd) diff --git a/src/util/platform/FFPlatform_windows.c b/src/util/platform/FFPlatform_windows.c index 71feae3f3..d95c9443f 100644 --- a/src/util/platform/FFPlatform_windows.c +++ b/src/util/platform/FFPlatform_windows.c @@ -129,6 +129,14 @@ static void getDataDirs(FFPlatform* platform) platformPathAddKnownFolder(&platform->dataDirs, &FOLDERID_RoamingAppData); platformPathAddKnownFolder(&platform->dataDirs, &FOLDERID_LocalAppData); ffPlatformPathAddHome(&platform->dataDirs, platform, ""); + + if (platform->exePath.length > 0) + { + // Add ${currentExePath} + FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateCopy(&platform->exePath); + ffStrbufSubstrBeforeLastC(&path, '/'); + ffPlatformPathAddAbsolute(&platform->dataDirs, path.chars); + } } static void getUserName(FFPlatform* platform)