Skip to content

Commit 8652737

Browse files
committed
Fastfetch: enhances config file loading with support for config directory
Fixes #2080
1 parent d6ac89e commit 8652737

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# 2.56.0
22

33
Features:
4+
* Enhances config file loading. `--config` and `-c` with relative path now also searches paths defined in `fastfetch --list-config-paths` (typically `~/.config/fastfetch/`)
5+
* This allows users to use `fastfetch -c my-config` without needing to specify the full path.
46
* Adds NUMA node count detection (CPU)
57
* Exposed via `{numa-nodes}` in custom format
68
* Supported on Linux, FreeBSD and Windows

src/fastfetch.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,20 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val
502502

503503
if (parseJsoncFile(absolutePath.chars, flag)) return;
504504

505-
//Try to load as a relative path
505+
//Try to load as a relative path with the config directory
506+
507+
FF_LIST_FOR_EACH(FFstrbuf, path, instance.state.platform.configDirs)
508+
{
509+
ffStrbufSet(&absolutePath, path);
510+
ffStrbufAppendS(&absolutePath, "fastfetch/");
511+
ffStrbufAppendS(&absolutePath, value);
512+
if (needExtension)
513+
ffStrbufAppendS(&absolutePath, ".jsonc");
514+
515+
if (parseJsoncFile(absolutePath.chars, flag)) return;
516+
}
517+
518+
//Try to load as a preset
506519

507520
FF_LIST_FOR_EACH(FFstrbuf, path, instance.state.platform.dataDirs)
508521
{
@@ -515,7 +528,7 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val
515528
if (parseJsoncFile(absolutePath.chars, flag)) return;
516529
}
517530

518-
//Try to load as a relative path with the directory of fastfetch binary
531+
//Try to load as a relative path with the directory of fastfetch binary, for Windows support
519532

520533
if (instance.state.platform.exePath.length)
521534
{

0 commit comments

Comments
 (0)