mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
--os-format
This commit is contained in:
@@ -6,6 +6,7 @@ __fastfetch_complete_help()
|
||||
"color"
|
||||
"battery-format"
|
||||
"packages-format"
|
||||
"os-format"
|
||||
)
|
||||
COMPREPLY=($(compgen -W "${__ff_helps[*]}" -- "$CURRENT_WORD"))
|
||||
}
|
||||
@@ -118,6 +119,7 @@ __fastfetch_completion()
|
||||
"--seperator"
|
||||
"-x"
|
||||
"--offsetx"
|
||||
"--os-format"
|
||||
"--packages-format"
|
||||
"--resolution-format"
|
||||
"--battery-format"
|
||||
|
||||
@@ -29,6 +29,7 @@ void ffDefaultConfig(FFconfig* config)
|
||||
config->cacheSave = true;
|
||||
|
||||
config->osShowArchitecture = true;
|
||||
config->osFormat[0] = '\0';
|
||||
|
||||
config->hostShowVersion = true;
|
||||
|
||||
|
||||
+19
-1
@@ -98,7 +98,8 @@ static inline void printHelp()
|
||||
" --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"
|
||||
" --os-architecture <?value>: Show the architecture of the os\n"
|
||||
" --os-format <format>: Provide the printf format string for os output (+)\n"
|
||||
"\n"
|
||||
"Host options:\n"
|
||||
" --host-version <?value>: Show the version of the host platform, if possible. Most likely, this will be the BIOS version\n"
|
||||
@@ -152,6 +153,19 @@ static inline void printCommandHelpColor()
|
||||
);
|
||||
}
|
||||
|
||||
static inline void printCommandHelpOsFormat()
|
||||
{
|
||||
puts(
|
||||
"usage fastfetch --os-format <format>\n"
|
||||
"\n"
|
||||
"<format> is a string of maximum length 32, which is passed to printf as the format string.\n"
|
||||
"The arguments passed to printf are 2 strings in following order:\n"
|
||||
"name, architecture\n"
|
||||
"If an value could not be determined, it will be an zero length string.\n"
|
||||
"The default value is something like \"%s %s\"."
|
||||
);
|
||||
}
|
||||
|
||||
static inline void printCommandHelpBatteryFormat()
|
||||
{
|
||||
puts(
|
||||
@@ -195,6 +209,8 @@ static inline void printCommandHelp(const char* command)
|
||||
{
|
||||
if(strcasecmp(command, "c") == 0 || strcasecmp(command, "color") == 0)
|
||||
printCommandHelpColor();
|
||||
else if(strcasecmp(command, "os-format") == 0)
|
||||
printCommandHelpOsFormat();
|
||||
else if(strcasecmp(command, "battery-format") == 0)
|
||||
printCommandHelpBatteryFormat();
|
||||
else if(strcasecmp(command, "packages-format") == 0)
|
||||
@@ -404,6 +420,8 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
instance->config.colorLogo = optionParseBoolean(value);
|
||||
else if(strcasecmp(key, "--os-architecture") == 0)
|
||||
instance->config.osShowArchitecture = optionParseBoolean(value);
|
||||
else if(strcasecmp(key, "--os-format") == 0)
|
||||
optionParseString(key, value, instance->config.osFormat, sizeof(instance->config.osFormat));
|
||||
else if(strcasecmp(key, "--host-version") == 0)
|
||||
instance->config.hostShowVersion = optionParseBoolean(value);
|
||||
else if(strcasecmp(key, "--kernel-release") == 0)
|
||||
|
||||
@@ -45,6 +45,7 @@ typedef struct FFconfig
|
||||
|
||||
//OS
|
||||
bool osShowArchitecture;
|
||||
char osFormat[32];
|
||||
|
||||
//Host
|
||||
bool hostShowVersion;
|
||||
|
||||
+4
-2
@@ -7,7 +7,7 @@ void ffPrintOS(FFinstance* instance)
|
||||
|
||||
char name[256];
|
||||
ffParsePropFile("/etc/os-release", "NAME=\"%[^\"]+", name);
|
||||
if(name[0] == '\0')
|
||||
if(name[0] == '\0' && instance->config.osFormat[0] == '\0') //With custom format string we pass an empty string as name
|
||||
{
|
||||
ffPrintError(instance, "OS", "\"NAME=\\\"%[^\\\"]+\" not found in \"/etc/os-release\"");
|
||||
return;
|
||||
@@ -15,7 +15,9 @@ void ffPrintOS(FFinstance* instance)
|
||||
|
||||
char os[1024];
|
||||
|
||||
if(instance->config.osShowArchitecture)
|
||||
if(instance->config.osFormat[0] != '\0')
|
||||
sprintf(os, instance->config.osFormat, name, instance->state.utsname.machine);
|
||||
else if(instance->config.osShowArchitecture)
|
||||
sprintf(os, "%s %s", name, instance->state.utsname.machine);
|
||||
else
|
||||
strcpy(os, name);
|
||||
|
||||
Reference in New Issue
Block a user