mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-09 06:30:10 +01:00
Merge pull request #389 from CarterLi/command
RFC: an attempt to add a new module which can run custom shell scripts
This commit is contained in:
@@ -350,6 +350,18 @@ static void defaultConfig(FFinstance* instance)
|
||||
ffStrbufInitA(&instance->config.playerName, 0);
|
||||
|
||||
instance->config.percentType = 1;
|
||||
|
||||
ffStrbufInitS(&instance->config.commandShell,
|
||||
#ifdef _WIN32
|
||||
"cmd"
|
||||
#elif defined(__FreeBSD__)
|
||||
"csh"
|
||||
#else
|
||||
"bash"
|
||||
#endif
|
||||
);
|
||||
ffListInit(&instance->config.commandKeys, sizeof(FFstrbuf));
|
||||
ffListInit(&instance->config.commandTexts, sizeof(FFstrbuf));
|
||||
}
|
||||
|
||||
void ffInitInstance(FFinstance* instance)
|
||||
@@ -564,6 +576,14 @@ static void destroyConfig(FFinstance* instance)
|
||||
ffStrbufDestroy(&instance->config.weatherOutputFormat);
|
||||
ffStrbufDestroy(&instance->config.osFile);
|
||||
ffStrbufDestroy(&instance->config.playerName);
|
||||
|
||||
ffStrbufDestroy(&instance->config.commandShell);
|
||||
FF_LIST_FOR_EACH(FFstrbuf, item, instance->config.commandKeys)
|
||||
ffStrbufDestroy(item);
|
||||
ffListDestroy(&instance->config.commandKeys);
|
||||
FF_LIST_FOR_EACH(FFstrbuf, item, instance->config.commandTexts)
|
||||
ffStrbufDestroy(item);
|
||||
ffListDestroy(&instance->config.commandTexts);
|
||||
}
|
||||
|
||||
static void destroyState(FFinstance* instance)
|
||||
|
||||
@@ -31,8 +31,8 @@ const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[])
|
||||
//Parent
|
||||
close(pipes[1]);
|
||||
waitpid(childPid, NULL, 0);
|
||||
ffAppendFDBuffer(pipes[0], buffer);
|
||||
bool ok = ffAppendFDBuffer(pipes[0], buffer);
|
||||
close(pipes[0]);
|
||||
|
||||
return NULL;
|
||||
return ok ? NULL : "ffAppendFDBuffer() failed";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user