mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 09:33:39 +01:00
better ffGetPropValue
This commit is contained in:
@@ -83,11 +83,11 @@ static void detectGTKFromConfigFile(const char* filename, FFGTKResult* result)
|
||||
while(getline(&line, &len, file) != -1)
|
||||
{
|
||||
if(result->theme.length == 0)
|
||||
ffGetPropValue(line, "gtk-theme-name=", &result->theme);
|
||||
ffGetPropValue(line, "gtk-theme-name =", &result->theme);
|
||||
if(result->icons.length == 0)
|
||||
ffGetPropValue(line, "gtk-icon-theme-name=", &result->icons);
|
||||
ffGetPropValue(line, "gtk-icon-theme-name =", &result->icons);
|
||||
if(result->font.length == 0)
|
||||
ffGetPropValue(line, "gtk-font-name=", &result->font);
|
||||
ffGetPropValue(line, "gtk-font-name =", &result->font);
|
||||
}
|
||||
|
||||
if(line != NULL)
|
||||
|
||||
@@ -42,13 +42,13 @@ static bool detectFromConfigFile(const FFstrbuf* filename, FFPlasmaResult* resul
|
||||
}
|
||||
|
||||
if(category == PLASMA_CATEGORY_KDE)
|
||||
ffGetPropValue(line, "widgetStyle=", &result->widgetStyle);
|
||||
ffGetPropValue(line, "widgetStyle =", &result->widgetStyle);
|
||||
else if(category == PLASMA_CATEGORY_ICONS)
|
||||
ffGetPropValue(line, "Theme=", &result->icons);
|
||||
ffGetPropValue(line, "Theme =", &result->icons);
|
||||
else if(category == PLASMA_CATEGORY_GENERAL)
|
||||
{
|
||||
ffGetPropValue(line, "ColorScheme=", &result->colorScheme);
|
||||
ffGetPropValue(line, "font=", &result->font);
|
||||
ffGetPropValue(line, "ColorScheme =", &result->colorScheme);
|
||||
ffGetPropValue(line, "font =", &result->font);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -212,21 +212,21 @@ static void getKDE(FFWMDEResult* result)
|
||||
{
|
||||
ffStrbufSetS(&result->deProcessName, "plasmashell");
|
||||
ffStrbufSetS(&result->dePrettyName, "KDE Plasma");
|
||||
ffParsePropFile("/usr/share/xsessions/plasma.desktop", "X-KDE-PluginInfo-Version=", &result->deVersion);
|
||||
ffParsePropFile("/usr/share/xsessions/plasma.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion);
|
||||
}
|
||||
|
||||
static void getGnome(FFWMDEResult* result)
|
||||
{
|
||||
ffStrbufSetS(&result->deProcessName, "gnome-shell");
|
||||
ffStrbufSetS(&result->dePrettyName, "GNOME");
|
||||
ffParsePropFile("/usr/share/gnome-shell/org.gnome.Extensions", "version: ", &result->deVersion);
|
||||
ffParsePropFile("/usr/share/gnome-shell/org.gnome.Extensions", "version :", &result->deVersion);
|
||||
}
|
||||
|
||||
static void getCinnamon(FFWMDEResult* result)
|
||||
{
|
||||
ffStrbufSetS(&result->deProcessName, "cinnamon");
|
||||
ffStrbufSetS(&result->dePrettyName, "Cinnamon");
|
||||
ffParsePropFile("/usr/share/applications/cinnamon.desktop", "X-GNOME-Bugzilla-Version=", &result->deVersion);
|
||||
ffParsePropFile("/usr/share/applications/cinnamon.desktop", "X-GNOME-Bugzilla-Version =", &result->deVersion);
|
||||
}
|
||||
|
||||
static void getMate(FFinstance* instance, FFWMDEResult* result)
|
||||
@@ -261,7 +261,7 @@ static void getXFCE4(FFinstance* instance, FFWMDEResult* result)
|
||||
{
|
||||
ffStrbufSetS(&result->deProcessName, "xfce4-session");
|
||||
ffStrbufSetS(&result->dePrettyName, "Xfce4");
|
||||
ffParsePropFile("/usr/share/gtk-doc/html/libxfce4ui/index.html", "<div><p class=\"releaseinfo\">Version ", &result->deVersion);
|
||||
ffParsePropFile("/usr/share/gtk-doc/html/libxfce4ui/index.html", "<div><p class=\"releaseinfo\">Version", &result->deVersion);
|
||||
|
||||
if(result->deVersion.length == 0 && instance->config.allowSlowOperations)
|
||||
{
|
||||
|
||||
@@ -118,7 +118,7 @@ bool ffGetPropValue(const char* line, const char* start, FFstrbuf* buffer)
|
||||
|
||||
while(start[startIndex] != '\0')
|
||||
{
|
||||
// Any amount of whitespace in the format string matches any amount of whitespace in the line
|
||||
// Any amount of whitespace in the format string matches any amount of whitespace in the line, even none
|
||||
if(start[startIndex] == ' ' || start[startIndex] == '\t')
|
||||
{
|
||||
while(start[startIndex] == ' ' || start[startIndex] == '\t')
|
||||
@@ -137,6 +137,10 @@ bool ffGetPropValue(const char* line, const char* start, FFstrbuf* buffer)
|
||||
++startIndex;
|
||||
}
|
||||
|
||||
//Skip any amount of whitespace at the begin of the value
|
||||
while(line[lineIndex] == ' ' || line[lineIndex] == '\t')
|
||||
++lineIndex;
|
||||
|
||||
//Allow quotet values
|
||||
const char* quotes = NULL;
|
||||
if(line[lineIndex] == '"' || line[lineIndex] == '\'')
|
||||
@@ -146,7 +150,7 @@ bool ffGetPropValue(const char* line, const char* start, FFstrbuf* buffer)
|
||||
while(line[lineIndex] != '\n' && line[lineIndex] != '\0' && (quotes == NULL || *quotes != line[lineIndex]))
|
||||
ffStrbufAppendC(buffer, line[lineIndex++]);
|
||||
|
||||
ffStrbufTrim(buffer, ' ');
|
||||
ffStrbufTrimRight(buffer, ' ');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user