diff --git a/completions/bash b/completions/bash index c52e999f7..15df090a8 100644 --- a/completions/bash +++ b/completions/bash @@ -109,11 +109,7 @@ __fastfetch_completion() "--recache" "--show-errors" "--color-logo" - "--battery-manufacturer" - "--battery-model" - "--battery-technology" - "--battery-capacity" - "--battery-status" + "--print-remaining-logo" ) local FF_OPTIONS_STRING=( diff --git a/src/common.c b/src/common.c index 712203150..5d2a7f2c3 100644 --- a/src/common.c +++ b/src/common.c @@ -30,6 +30,7 @@ void ffDefaultConfig(FFconfig* config) config->showErrors = false; config->recache = false; config->cacheSave = true; + config->printRemainingLogo = true; ffStrbufInit(&config->osFormat); ffStrbufInit(&config->hostFormat); @@ -57,6 +58,47 @@ void ffDefaultConfig(FFconfig* config) ffStrbufInitA(&config->libXrandr, 256); } +static void ffCleanup(FFinstance* instance) +{ + ffStrbufDestroy(&instance->config.color); + ffStrbufDestroy(&instance->config.seperator); + + ffStrbufDestroy(&instance->config.osFormat); + ffStrbufDestroy(&instance->config.hostFormat); + ffStrbufDestroy(&instance->config.kernelFormat); + ffStrbufDestroy(&instance->config.uptimeFormat); + ffStrbufDestroy(&instance->config.packagesFormat); + ffStrbufDestroy(&instance->config.shellFormat); + ffStrbufDestroy(&instance->config.resolutionFormat); + ffStrbufDestroy(&instance->config.deFormat); + ffStrbufDestroy(&instance->config.wmFormat); + ffStrbufDestroy(&instance->config.themeFormat); + ffStrbufDestroy(&instance->config.iconsFormat); + ffStrbufDestroy(&instance->config.fontFormat); + ffStrbufDestroy(&instance->config.terminalFormat); + ffStrbufDestroy(&instance->config.termFontFormat); + ffStrbufDestroy(&instance->config.cpuFormat); + ffStrbufDestroy(&instance->config.gpuFormat); + ffStrbufDestroy(&instance->config.memoryFormat); + ffStrbufDestroy(&instance->config.diskFormat); + ffStrbufDestroy(&instance->config.batteryFormat); + ffStrbufDestroy(&instance->config.localeFormat); + + ffStrbufDestroy(&instance->config.libPCI); + ffStrbufDestroy(&instance->config.libX11); + ffStrbufDestroy(&instance->config.libXrandr); + + ffStrbufDestroy(&instance->state.terminal.value); +} + +void ffFinish(FFinstance* instance) +{ + if(instance->config.printRemainingLogo) + ffPrintRemainingLogo(instance); + + ffCleanup(instance); +} + void ffPrintKey(FFconfig* config, const char* key) { printf(FASTFETCH_TEXT_MODIFIER_BOLT"%s%s"FASTFETCH_TEXT_MODIFIER_RESET"%s", config->color.chars, key, config->seperator.chars); diff --git a/src/fastfetch.c b/src/fastfetch.c index f0b8f98f8..18665b797 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -42,14 +42,15 @@ static inline void printHelp() " --print-default-config: prints the default config and exits\n" "\n" "General options:\n" - " --structure : sets the structure of the fetch. Must be a colon seperated list of keys\n" - " --set : hard set the value of an key\n" - " -c , --color : sets the color of the keys. Must be a linux console color code (+)\n" - " --spacer : sets the distance between logo and text\n" - " -s , --seperator : sets the seperator between key and value. Default is a colon with a space\n" - " -x , --offsetx : sets the x offset. Can be negative to cut the logo, but no more than logo width.\n" - " --show-errors : print occuring errors\n" - " -r --recache : if set to true, no cached values will be used\n" + " --structure : sets the structure of the fetch. Must be a colon seperated list of keys\n" + " --set : hard set the value of an key\n" + " -c , --color : sets the color of the keys. Must be a linux console color code (+)\n" + " --spacer : sets the distance between logo and text\n" + " -s , --seperator : sets the seperator between key and value. Default is a colon with a space\n" + " -x , --offsetx : sets the x offset. Can be negative to cut the logo, but no more than logo width.\n" + " --show-errors : print occuring errors\n" + " -r --recache : if set to true, no cached values will be used\n" + " --print-remaining-logo : print the remaining logo, if it is higher than the number of lines shown\n" "\n" "Logo options:\n" " -l , --logo : sets the shown logo. Also changes the main color accordingly\n" @@ -400,6 +401,8 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con instance->config.showErrors = optionParseBoolean(value); else if(strcasecmp(key, "--color-logo") == 0) instance->config.colorLogo = optionParseBoolean(value); + else if(strcasecmp(key, "--print-remaining-logo") == 0) + instance->config.printRemainingLogo = optionParseBoolean(value); else if(strcasecmp(key, "--structure") == 0) optionParseString(key, value, &data->structure); else if(strcasecmp(key, "-l") == 0 || strcasecmp(key, "--logo") == 0) @@ -691,5 +694,9 @@ int main(int argc, const char** argv) run(&instance, &data); + ffFinish(&instance); + + ffStrbufDestroy(&data.structure); + ffStrbufDestroy(&data.logoName); ffValuestoreDelete(&data.valuestore); } diff --git a/src/fastfetch.h b/src/fastfetch.h index 9b216dc2a..e6841207c 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -43,6 +43,7 @@ typedef struct FFconfig bool showErrors; bool recache; bool cacheSave; //This is only set to true when using arguments, because we dont want so save this values + bool printRemainingLogo; FFstrbuf osFormat; FFstrbuf hostFormat; @@ -125,11 +126,13 @@ void ffTrimTrailingWhitespace(char* buffer); bool ffPrintCachedValue(FFinstance* instance, const char* key); void ffPrintAndSaveCachedValue(FFinstance* instance, const char* key, const char* value); void ffParseFormatString(FFstrbuf* buffer, FFstrbuf* formatstr, uint32_t numArgs, ...); +void ffFinish(FFinstance* instance); //Logo functions void ffLoadLogoSet(FFconfig* config, const char* logo); void ffLoadLogo(FFconfig* config); void ffPrintLogoLine(FFinstance* instance); +void ffPrintRemainingLogo(FFinstance* instance); #ifndef FLASHFETCH_BUILD_FLASHFATCH void ffListLogos(); diff --git a/src/flashfetch.c b/src/flashfetch.c index 8a8ec94a1..a0ce2a016 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -36,5 +36,6 @@ int main(int argc, char** argv) ffPrintBreak(&instance); ffPrintColors(&instance); + ffFinish(&instance); return 0; } \ No newline at end of file diff --git a/src/logo.c b/src/logo.c index 57a866301..d4dd4b9c6 100644 --- a/src/logo.c +++ b/src/logo.c @@ -230,6 +230,15 @@ void ffPrintLogoLine(FFinstance* instance) ++instance->state.current_row; } +void ffPrintRemainingLogo(FFinstance* instance) +{ + while(instance->state.current_row < instance->config.logo.height) + { + ffPrintLogoLine(instance); + putchar('\n'); + } +} + #ifndef FASTFETCH_BUILD_FLASHFETCH static FFlogo* getLogos(uint8_t* size, bool color)