mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 08:13:44 +01:00
--os-architecture option
This commit is contained in:
@@ -20,6 +20,7 @@ set(PROJECT_VERSION "r${GIT_REV_LIST}.${GIT_REV_PARSE}")
|
||||
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -march=native -O3 -pipe -fno-plt") # for testing
|
||||
|
||||
configure_file(src/fastfetch_config.h.in fastfetch_config.h)
|
||||
|
||||
include_directories(
|
||||
${PROJECT_BINARY_DIR}
|
||||
${PROJECT_SOURCE_DIR}/src
|
||||
|
||||
@@ -24,6 +24,9 @@ void ffDefaultConfig(FFconfig* config)
|
||||
config->colorLogo = true;
|
||||
config->showErrors = false;
|
||||
config->recache = false;
|
||||
config->cacheSave = true;
|
||||
|
||||
config->osShowArchitecture = true;
|
||||
|
||||
config->shellShowPath = false;
|
||||
|
||||
@@ -221,6 +224,9 @@ void ffPrintAndSaveCachedValue(FFinstance* instance, const char* key, const char
|
||||
ffPrintLogoAndKey(instance, key);
|
||||
puts(value);
|
||||
|
||||
if(!instance->config.cacheSave)
|
||||
return;
|
||||
|
||||
char fileName[256];
|
||||
strcpy(fileName, getCacheDir(instance));
|
||||
strcat(fileName, key);
|
||||
|
||||
@@ -31,6 +31,9 @@
|
||||
"## Logo options:\n" \
|
||||
"# --color-logo true\n" \
|
||||
"\n" \
|
||||
"## OS options:\n" \
|
||||
"# --os-architecture true\n" \
|
||||
"\n" \
|
||||
"## Shell options:\n" \
|
||||
"# --shell-path false\n" \
|
||||
"\n" \
|
||||
@@ -76,6 +79,9 @@ static void printHelp()
|
||||
" -l <name>, --logo <name>: sets the shown logo. Also changes the main color accordingly\n"
|
||||
" --color-logo <?value>: if set to false, the logo will be black / white\n"
|
||||
"\n"
|
||||
"OS options:\n"
|
||||
" --os-architecture <?value>: Show the architecture of the os\n"
|
||||
"\n"
|
||||
"Shell options:\n"
|
||||
" --shell-path <?value>: Show the full path of the shell\n"
|
||||
"\n"
|
||||
@@ -341,10 +347,24 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
}
|
||||
else if(strcasecmp(key, "-r") == 0 || strcasecmp(key, "--recache") == 0)
|
||||
{
|
||||
//Set cacheSave as well, beacuse the user expects the values to be cached when expliciting using --recache
|
||||
if(value == NULL)
|
||||
{
|
||||
instance->config.recache = true;
|
||||
instance->config.cacheSave = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
instance->config.recache = parseBoolean(value);
|
||||
instance->config.cacheSave = instance->config.recache;
|
||||
}
|
||||
}
|
||||
else if(strcasecmp(key, "--os-architecture") == 0)
|
||||
{
|
||||
if(value == NULL)
|
||||
instance->config.osShowArchitecture = true;
|
||||
else
|
||||
instance->config.osShowArchitecture = parseBoolean(value);
|
||||
}
|
||||
else if(strcasecmp(key, "--shell-path") == 0)
|
||||
{
|
||||
@@ -502,6 +522,15 @@ static void parseConfigFile(FFinstance* instance, FFdata* data)
|
||||
|
||||
static void parseArguments(FFinstance* instance, FFdata* data, int argc, const char** argv)
|
||||
{
|
||||
//This is generally a good idea, because cached values most likely contain values generated with other arguments
|
||||
//Hovwever we dont do this with arguments in the config file, because they are more likely to stay the same
|
||||
//If caching is _really_ wanted (e.g. a call in .bashrc with arguments), one can still set --recache false
|
||||
if(argc > 1)
|
||||
{
|
||||
instance->config.recache = true;
|
||||
instance->config.cacheSave = false;
|
||||
}
|
||||
|
||||
for(int i = 1; i < argc; i++)
|
||||
{
|
||||
if(i == argc - 1 || argv[i + 1][0] == '-')
|
||||
|
||||
@@ -31,6 +31,7 @@ typedef struct FFlogo
|
||||
|
||||
typedef struct FFconfig
|
||||
{
|
||||
//General
|
||||
FFlogo logo;
|
||||
uint16_t logo_spacer;
|
||||
char seperator[16];
|
||||
@@ -40,9 +41,15 @@ typedef struct FFconfig
|
||||
bool colorLogo;
|
||||
bool showErrors;
|
||||
bool recache;
|
||||
bool cacheSave; //This is only set to true when using arguments, because we dont want so save this values
|
||||
|
||||
//OS
|
||||
bool osShowArchitecture;
|
||||
|
||||
//Shell
|
||||
bool shellShowPath;
|
||||
|
||||
//Battery
|
||||
char batteryFormat[32];
|
||||
bool batteryShowManufacturer;
|
||||
bool batteryShowModel;
|
||||
|
||||
+5
-1
@@ -14,7 +14,11 @@ void ffPrintOS(FFinstance* instance)
|
||||
}
|
||||
|
||||
char os[1024];
|
||||
sprintf(os, "%s %s", name, instance->state.utsname.machine);
|
||||
|
||||
if(instance->config.osShowArchitecture)
|
||||
sprintf(os, "%s %s", name, instance->state.utsname.machine);
|
||||
else
|
||||
strcpy(os, name);
|
||||
|
||||
ffPrintAndSaveCachedValue(instance, "OS", os);
|
||||
}
|
||||
Reference in New Issue
Block a user