mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
support for --shell-path
This commit is contained in:
@@ -25,6 +25,8 @@ void ffDefaultConfig(FFconfig* config)
|
||||
config->showErrors = false;
|
||||
config->recache = false;
|
||||
|
||||
config->shellShowPath = false;
|
||||
|
||||
config->batteryShowManufacturer = true;
|
||||
config->batteryShowModel = true;
|
||||
config->batteryShowTechnology = true;
|
||||
|
||||
+15
-2
@@ -31,6 +31,9 @@
|
||||
"## Logo options:\n" \
|
||||
"# --color-logo true\n" \
|
||||
"\n" \
|
||||
"## Shell options:\n" \
|
||||
"# --shell-path false\n" \
|
||||
"\n" \
|
||||
"## Battery options:\n" \
|
||||
"# --battery-manufacturer true\n" \
|
||||
"# --battery-model true\n" \
|
||||
@@ -73,6 +76,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"
|
||||
"Shell options:\n"
|
||||
" --shell-path <?value>: Show the full path of the shell\n"
|
||||
"\n"
|
||||
"Battery options:\n"
|
||||
" --battery-manufacturer <?value>: Show the manufacturer of the battery, if possible\n"
|
||||
" --battery-model <?value>: Show the model of the battery, if possible\n"
|
||||
@@ -340,6 +346,13 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
else
|
||||
instance->config.recache = parseBoolean(value);
|
||||
}
|
||||
else if(strcasecmp(key, "--shell-path") == 0)
|
||||
{
|
||||
if(value == NULL)
|
||||
instance->config.shellShowPath = true;
|
||||
else
|
||||
instance->config.shellShowPath = parseBoolean(value);
|
||||
}
|
||||
else if(strcasecmp(key, "--battery-manufacturer") == 0)
|
||||
{
|
||||
if(value == NULL)
|
||||
@@ -466,7 +479,7 @@ static void parseConfigFile(FFinstance* instance, FFdata* data)
|
||||
while(*valueStart == ' ')
|
||||
++valueStart;
|
||||
|
||||
//If we want whitespace in values, we need to quote it. This is done to keep consistency whith shell.
|
||||
//If we want whitespace in values, we need to quote it. This is done to keep consistency with shell.
|
||||
if(*valueStart == '"')
|
||||
{
|
||||
char* last = valueStart + strlen(valueStart) - 1;
|
||||
@@ -553,7 +566,7 @@ int main(int argc, const char** argv)
|
||||
|
||||
parseConfigFile(&instance, &data);
|
||||
parseArguments(&instance, &data, argc, argv);
|
||||
applyData(&instance, &data);
|
||||
applyData(&instance, &data); //Here we do things that need to be done after parsing all options
|
||||
|
||||
run(&instance, &data);
|
||||
|
||||
|
||||
@@ -41,6 +41,8 @@ typedef struct FFconfig
|
||||
bool showErrors;
|
||||
bool recache;
|
||||
|
||||
bool shellShowPath;
|
||||
|
||||
char batteryFormat[32];
|
||||
bool batteryShowManufacturer;
|
||||
bool batteryShowModel;
|
||||
|
||||
+14
-6
@@ -12,12 +12,20 @@ void ffPrintShell(FFinstance* instance)
|
||||
return;
|
||||
}
|
||||
|
||||
char* shellName = strrchr(shellPath, '/');
|
||||
char* value;
|
||||
|
||||
if(shellName == NULL)
|
||||
shellName = shellPath;
|
||||
else if(shellName[0] == '/')
|
||||
++shellName;
|
||||
if(!instance->config.shellShowPath)
|
||||
{
|
||||
char* shellName = strrchr(shellPath, '/');
|
||||
if(shellName != NULL)
|
||||
value = ++shellName;
|
||||
else
|
||||
value = shellPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = shellPath;
|
||||
}
|
||||
|
||||
ffPrintAndSaveCachedValue(instance, "Shell", shellName);
|
||||
ffPrintAndSaveCachedValue(instance, "Shell", value);
|
||||
}
|
||||
Reference in New Issue
Block a user