mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
+14
-18
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user