diff --git a/CMakeLists.txt b/CMakeLists.txt index f8a8c99b1..497c429a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/src/common.c b/src/common.c index 5f3ecc5a6..9f48f1632 100644 --- a/src/common.c +++ b/src/common.c @@ -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); diff --git a/src/fastfetch.c b/src/fastfetch.c index 78b880925..930721444 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -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 , --logo : sets the shown logo. Also changes the main color accordingly\n" " --color-logo : if set to false, the logo will be black / white\n" "\n" + "OS options:\n" + " --os-architecture : Show the architecture of the os\n" + "\n" "Shell options:\n" " --shell-path : 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] == '-') diff --git a/src/fastfetch.h b/src/fastfetch.h index a504611f8..91b298cab 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -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; diff --git a/src/modules/os.c b/src/modules/os.c index a89013366..0453dd737 100644 --- a/src/modules/os.c +++ b/src/modules/os.c @@ -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); } \ No newline at end of file