mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Merge branch 'LinusDierheimer:master' into master
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
--structure OS:Kernel:Shell:DE:WM:WMTheme:Theme:Icons:Font:Terminal:TerminalFont
|
||||
--structure OS:Kernel:Shell:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Terminal:TerminalFont
|
||||
|
||||
+10
-9
@@ -67,15 +67,18 @@ static void detectGTKFromDConf(FFinstance* instance, FFGTKResult* result)
|
||||
themeName = ffSettingsGet(instance, "/org/mate/interface/gtk-theme", "org.mate.interface", NULL, "gtk-theme", FF_VARIANT_TYPE_STRING).strValue;
|
||||
iconsName = ffSettingsGet(instance, "/org/mate/interface/icon-theme", "org.mate.interface", NULL, "icon-theme", FF_VARIANT_TYPE_STRING).strValue;
|
||||
fontName = ffSettingsGet(instance, "/org/mate/interface/font-name", "org.mate.interface", NULL, "font-name", FF_VARIANT_TYPE_STRING).strValue;
|
||||
cursorTheme = ffSettingsGet(instance, "/org/mate/interface/cursor-theme", "org.mate.interface", NULL, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue;
|
||||
cursorSize = ffSettingsGet(instance, "/org/mate/interface/cursor-size", "org.mate.interface", NULL, "cursor-size", FF_VARIANT_TYPE_INT).intValue;
|
||||
cursorTheme = ffSettingsGet(instance, "/org/mate/peripherals-mouse/cursor-theme", "org.mate.peripherals-mouse", NULL, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue;
|
||||
cursorSize = ffSettingsGet(instance, "/org/mate/peripherals-mouse/cursor-size", "org.mate.peripherals-mouse", NULL, "cursor-size", FF_VARIANT_TYPE_INT).intValue;
|
||||
}
|
||||
|
||||
//Fallback + Gnome impl
|
||||
|
||||
if(themeName == NULL)
|
||||
themeName = ffSettingsGet(instance, "/org/gnome/desktop/interface/gtk-theme", "org.gnome.desktop.interface", NULL, "gtk-theme", FF_VARIANT_TYPE_STRING).strValue;
|
||||
|
||||
if(iconsName == NULL)
|
||||
iconsName = ffSettingsGet(instance, "/org/gnome/desktop/interface/icon-theme", "org.gnome.desktop.interface", NULL, "icon-theme", FF_VARIANT_TYPE_STRING).strValue;
|
||||
|
||||
if(fontName == NULL)
|
||||
fontName = ffSettingsGet(instance, "/org/gnome/desktop/interface/font-name", "org.gnome.desktop.interface", NULL, "font-name", FF_VARIANT_TYPE_STRING).strValue;
|
||||
|
||||
@@ -149,25 +152,23 @@ static void detectGTK(FFinstance* instance, const char* version, const char* env
|
||||
FFstrbuf buffer;
|
||||
ffStrbufInitA(&buffer, 128);
|
||||
|
||||
uint32_t lastIndex;
|
||||
|
||||
// From ENV: GTK*_RC_FILES
|
||||
|
||||
ffStrbufSetS(&buffer, getenv(envVariable));
|
||||
lastIndex = 0;
|
||||
while (lastIndex < buffer.length)
|
||||
uint32_t startIndex = 0;
|
||||
while (startIndex < buffer.length)
|
||||
{
|
||||
uint32_t colonIndex = ffStrbufFirstIndexAfterC(&buffer, lastIndex, ':');
|
||||
uint32_t colonIndex = ffStrbufNextIndexC(&buffer, startIndex, ':');
|
||||
buffer.chars[colonIndex] = '\0';
|
||||
|
||||
detectGTKFromConfigFile(buffer.chars + lastIndex, result);
|
||||
detectGTKFromConfigFile(buffer.chars + startIndex, result);
|
||||
if(allPropertiesSet(result))
|
||||
{
|
||||
ffStrbufDestroy(&buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
lastIndex = colonIndex + 1;
|
||||
startIndex = colonIndex + 1;
|
||||
}
|
||||
|
||||
//From DConf / GSettings
|
||||
|
||||
+2
-2
@@ -210,7 +210,7 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, const FFst
|
||||
}
|
||||
|
||||
// fastforward to the end of the if without printing the in between
|
||||
i = ffStrbufFirstIndexAfterS(formatstr, i, "{?}") + 2; // 2 is the length of "{?}" -1 because the loop will increament it again directly after continue
|
||||
i = ffStrbufNextIndexS(formatstr, i, "{?}") + 2; // 2 is the length of "{?}" - 1 because the loop will increament it again directly after continue
|
||||
ffStrbufDestroy(&placeholderValue);
|
||||
continue;
|
||||
}
|
||||
@@ -247,7 +247,7 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, const FFst
|
||||
}
|
||||
|
||||
// fastforward to the end of the if without printing the in between
|
||||
i = ffStrbufFirstIndexAfterS(formatstr, i, "{/}") + 2; // 2 is the length of "{/}" -1 because the loop will increament it again directly after continue
|
||||
i = ffStrbufNextIndexS(formatstr, i, "{/}") + 2; // 2 is the length of "{/}" - 1 because the loop will increament it again directly after continue
|
||||
ffStrbufDestroy(&placeholderValue);
|
||||
continue;
|
||||
}
|
||||
|
||||
+8
-6
@@ -22,19 +22,21 @@ static void initConfigDirs(FFstate* state)
|
||||
}
|
||||
|
||||
FFstrbuf xdgConfigDirs;
|
||||
ffStrbufInitAS(&xdgConfigDirs, 64, getenv("XDG_CONFIG_DIRS"));
|
||||
uint32_t lastIndex = 0;
|
||||
while (lastIndex < xdgConfigDirs.length)
|
||||
ffStrbufInitA(&xdgConfigDirs, 64);
|
||||
ffStrbufAppendS(&xdgConfigDirs, getenv("XDG_CONFIG_DIRS"));
|
||||
|
||||
uint32_t startIndex = 0;
|
||||
while (startIndex < xdgConfigDirs.length)
|
||||
{
|
||||
uint32_t colonIndex = ffStrbufFirstIndexAfterC(&xdgConfigDirs, lastIndex, ':');
|
||||
uint32_t colonIndex = ffStrbufNextIndexC(&xdgConfigDirs, startIndex, ':');
|
||||
xdgConfigDirs.chars[colonIndex] = '\0';
|
||||
|
||||
FFstrbuf* buffer = (FFstrbuf*) ffListAdd(&state->configDirs);
|
||||
ffStrbufInitA(buffer, 64);
|
||||
ffStrbufAppendS(buffer, xdgConfigDirs.chars + lastIndex);
|
||||
ffStrbufAppendS(buffer, xdgConfigDirs.chars + startIndex);
|
||||
ffStrbufTrimRight(buffer, '/');
|
||||
|
||||
lastIndex = colonIndex + 1;
|
||||
startIndex = colonIndex + 1;
|
||||
}
|
||||
|
||||
#define FF_ENSURE_ONLY_ONCE_IN_LIST(element) \
|
||||
|
||||
+10
-10
@@ -128,14 +128,14 @@ static bool printCachedValue(FFinstance* instance, const char* moduleName, const
|
||||
|
||||
uint8_t moduleCounter = 1;
|
||||
|
||||
uint32_t lastIndex = 0;
|
||||
while(lastIndex < content.length)
|
||||
uint32_t startIndex = 0;
|
||||
while(startIndex < content.length)
|
||||
{
|
||||
uint32_t nullByteIndex = ffStrbufFirstIndexAfterC(&content, lastIndex, '\0');
|
||||
uint32_t nullByteIndex = ffStrbufNextIndexC(&content, startIndex, '\0');
|
||||
uint8_t moduleIndex = (moduleCounter == 1 && nullByteIndex == content.length) ? 0 : moduleCounter;
|
||||
ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat);
|
||||
puts(content.chars + lastIndex);
|
||||
lastIndex = nullByteIndex + 1;
|
||||
puts(content.chars + startIndex);
|
||||
startIndex = nullByteIndex + 1;
|
||||
++moduleCounter;
|
||||
}
|
||||
|
||||
@@ -160,14 +160,14 @@ static bool printCachedFormat(FFinstance* instance, const char* moduleName, cons
|
||||
FFformatarg* arguments = calloc(numArgs, sizeof(FFformatarg));
|
||||
uint32_t argumentCounter = 0;
|
||||
|
||||
uint32_t lastIndex = 0;
|
||||
while(lastIndex < content.length)
|
||||
uint32_t startIndex = 0;
|
||||
while(startIndex < content.length)
|
||||
{
|
||||
arguments[argumentCounter].type = FF_FORMAT_ARG_TYPE_STRING;
|
||||
arguments[argumentCounter].value = &content.chars[lastIndex];
|
||||
arguments[argumentCounter].value = &content.chars[startIndex];
|
||||
++argumentCounter;
|
||||
|
||||
uint32_t nullByteIndex = ffStrbufFirstIndexAfterC(&content, lastIndex, '\0');
|
||||
uint32_t nullByteIndex = ffStrbufNextIndexC(&content, startIndex, '\0');
|
||||
|
||||
if(argumentCounter == numArgs)
|
||||
{
|
||||
@@ -177,7 +177,7 @@ static bool printCachedFormat(FFinstance* instance, const char* moduleName, cons
|
||||
argumentCounter = 0;
|
||||
}
|
||||
|
||||
lastIndex = nullByteIndex + 1;
|
||||
startIndex = nullByteIndex + 1;
|
||||
}
|
||||
|
||||
free(arguments);
|
||||
|
||||
+5
-5
@@ -1079,15 +1079,15 @@ static void run(FFinstance* instance, FFdata* data)
|
||||
|
||||
ffStart(instance);
|
||||
|
||||
uint32_t lastIndex = 0;
|
||||
while (lastIndex < data->structure.length)
|
||||
uint32_t startIndex = 0;
|
||||
while (startIndex < data->structure.length)
|
||||
{
|
||||
uint32_t colonIndex = ffStrbufFirstIndexAfterC(&data->structure, lastIndex, ':');
|
||||
uint32_t colonIndex = ffStrbufNextIndexC(&data->structure, startIndex, ':');
|
||||
data->structure.chars[colonIndex] = '\0';
|
||||
|
||||
parseStructureCommand(instance, data, data->structure.chars + lastIndex);
|
||||
parseStructureCommand(instance, data, data->structure.chars + startIndex);
|
||||
|
||||
lastIndex = colonIndex + 1;
|
||||
startIndex = colonIndex + 1;
|
||||
}
|
||||
|
||||
ffFinish(instance);
|
||||
|
||||
@@ -57,12 +57,17 @@ static void printBattery(FFinstance* instance, FFstrbuf* dir, uint32_t index)
|
||||
putchar('%');
|
||||
|
||||
if(showStatus)
|
||||
fputs("; ", stdout);
|
||||
fputs(" [", stdout);
|
||||
}
|
||||
|
||||
if(showStatus)
|
||||
{
|
||||
ffStrbufWriteTo(&status, stdout);
|
||||
|
||||
if(capacity.length > 0)
|
||||
putchar(']');
|
||||
}
|
||||
|
||||
putchar('\n');
|
||||
}
|
||||
else
|
||||
|
||||
+100
-4
@@ -8,11 +8,11 @@ static void printCursor(FFinstance* instance, const FFstrbuf* cursorTheme, const
|
||||
ffPrintLogoAndKey(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursorKey);
|
||||
ffStrbufWriteTo(cursorTheme, stdout);
|
||||
|
||||
if(cursorSize->length > 0)
|
||||
if(cursorSize != NULL && cursorSize->length > 0)
|
||||
{
|
||||
fputs(" (", stdout);
|
||||
ffStrbufWriteTo(cursorSize, stdout);
|
||||
fputs("pt)", stdout);
|
||||
fputs("px)", stdout);
|
||||
}
|
||||
|
||||
putchar('\n');
|
||||
@@ -91,14 +91,110 @@ static void printCursorXFCE(FFinstance* instance)
|
||||
ffStrbufDestroy(&cursorSize);
|
||||
}
|
||||
|
||||
static bool printCursorFromXResources(FFinstance* instance)
|
||||
{
|
||||
FFstrbuf theme;
|
||||
ffStrbufInit(&theme);
|
||||
|
||||
FFstrbuf size;
|
||||
ffStrbufInit(&size);
|
||||
|
||||
ffParsePropFileHomeValues(instance, ".Xresources", 2, (FFpropquery[]) {
|
||||
{"Xcursor.theme :", &theme},
|
||||
{"Xcursor.size :", &size}
|
||||
});
|
||||
|
||||
if(theme.length == 0)
|
||||
{
|
||||
ffStrbufDestroy(&size);
|
||||
ffStrbufDestroy(&theme);
|
||||
return false;
|
||||
}
|
||||
|
||||
printCursor(instance, &theme, &size);
|
||||
ffStrbufDestroy(&size);
|
||||
ffStrbufDestroy(&theme);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool printCursorFromXDG(FFinstance* instance, bool user)
|
||||
{
|
||||
FFstrbuf theme;
|
||||
ffStrbufInit(&theme);
|
||||
|
||||
if(user)
|
||||
ffParsePropFileHome(instance, ".icons/default/index.theme", "Inherits =", &theme);
|
||||
else
|
||||
ffParsePropFile("/usr/share/icons/default/index.theme", "Inherits =", &theme);
|
||||
|
||||
if(theme.length == 0)
|
||||
{
|
||||
ffStrbufDestroy(&theme);
|
||||
return false;
|
||||
}
|
||||
|
||||
printCursor(instance, &theme, NULL);
|
||||
ffStrbufDestroy(&theme);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool printCursorFromEnv(FFinstance* instance)
|
||||
{
|
||||
const char* xcursor_theme = getenv("XCURSOR_THEME");
|
||||
|
||||
if(xcursor_theme == NULL || *xcursor_theme == '\0')
|
||||
return false;
|
||||
|
||||
FFstrbuf theme;
|
||||
ffStrbufInit(&theme);
|
||||
ffStrbufAppendS(&theme, xcursor_theme);
|
||||
|
||||
FFstrbuf size;
|
||||
ffStrbufInit(&size);
|
||||
ffStrbufAppendS(&size, getenv("XCURSOR_SIZE"));
|
||||
|
||||
printCursor(instance, &theme, &size);
|
||||
|
||||
ffStrbufDestroy(&size);
|
||||
ffStrbufDestroy(&theme);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ffPrintCursor(FFinstance* instance)
|
||||
{
|
||||
if(printCursorFromEnv(instance))
|
||||
return;
|
||||
|
||||
const FFWMDEResult* wmde = ffDetectWMDE(instance);
|
||||
|
||||
if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "KDE Plasma") == 0)
|
||||
{
|
||||
printCursorPlasma(instance);
|
||||
else if(ffStrbufStartsWithIgnCaseS(&wmde->dePrettyName, "XFCE"))
|
||||
return;
|
||||
}
|
||||
|
||||
if(ffStrbufStartsWithIgnCaseS(&wmde->dePrettyName, "XFCE"))
|
||||
{
|
||||
printCursorXFCE(instance);
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Gnome") == 0 || ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Cinnamon") == 0 || ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Mate") == 0)
|
||||
{
|
||||
printCursorGTK(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
//User config
|
||||
if(printCursorFromXDG(instance, true))
|
||||
return;
|
||||
|
||||
if(printCursorFromXResources(instance))
|
||||
return;
|
||||
|
||||
//System config
|
||||
if(printCursorFromXDG(instance, false))
|
||||
return;
|
||||
|
||||
printCursorGTK(instance);
|
||||
}
|
||||
|
||||
+5
-5
@@ -114,15 +114,15 @@ void ffPrintDisk(FFinstance* instance)
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t lastIndex = 0;
|
||||
while (lastIndex < instance->config.diskFolders.length)
|
||||
uint32_t startIndex = 0;
|
||||
while (startIndex < instance->config.diskFolders.length)
|
||||
{
|
||||
uint32_t colonIndex = ffStrbufFirstIndexAfterC(&instance->config.diskFolders, lastIndex, ':');
|
||||
uint32_t colonIndex = ffStrbufNextIndexC(&instance->config.diskFolders, startIndex, ':');
|
||||
instance->config.diskFolders.chars[colonIndex] = '\0';
|
||||
|
||||
printFolder(instance, instance->config.diskFolders.chars + lastIndex);
|
||||
printFolder(instance, instance->config.diskFolders.chars + startIndex);
|
||||
|
||||
lastIndex = colonIndex + 1;
|
||||
startIndex = colonIndex + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+17
-8
@@ -381,7 +381,7 @@ void ffStrbufRemoveStrings(FFstrbuf* strbuf, uint32_t numStrings, ...)
|
||||
va_end(argp);
|
||||
}
|
||||
|
||||
uint32_t ffStrbufFirstIndexAfterC(const FFstrbuf* strbuf, uint32_t start, const char c)
|
||||
uint32_t ffStrbufNextIndexC(const FFstrbuf* strbuf, uint32_t start, char c)
|
||||
{
|
||||
for(uint32_t i = start; i < strbuf->length; i++)
|
||||
{
|
||||
@@ -391,14 +391,14 @@ uint32_t ffStrbufFirstIndexAfterC(const FFstrbuf* strbuf, uint32_t start, const
|
||||
return strbuf->length;
|
||||
}
|
||||
|
||||
uint32_t ffStrbufFirstIndexC(const FFstrbuf* strbuf, const char c)
|
||||
uint32_t ffStrbufFirstIndexC(const FFstrbuf* strbuf, char c)
|
||||
{
|
||||
return ffStrbufFirstIndexAfterC(strbuf, 0, c);
|
||||
return ffStrbufNextIndexC(strbuf, 0, c);
|
||||
}
|
||||
|
||||
uint32_t ffStrbufFirstIndexAfterS(const FFstrbuf* strbuf, uint32_t start, const char* str)
|
||||
uint32_t ffStrbufNextIndexS(const FFstrbuf* strbuf, uint32_t start, const char* str)
|
||||
{
|
||||
for(uint32_t i = start + 1; i < strbuf->length; i++)
|
||||
for(uint32_t i = start; i < strbuf->length; i++)
|
||||
{
|
||||
bool found = true;
|
||||
|
||||
@@ -417,18 +417,22 @@ uint32_t ffStrbufFirstIndexAfterS(const FFstrbuf* strbuf, uint32_t start, const
|
||||
if(found)
|
||||
return i;
|
||||
}
|
||||
|
||||
return strbuf->length;
|
||||
}
|
||||
|
||||
uint32_t ffStrbufFirstIndexS(const FFstrbuf* strbuf, const char* str)
|
||||
{
|
||||
return ffStrbufFirstIndexAfterS(strbuf, 0, str);
|
||||
return ffStrbufNextIndexS(strbuf, 0, str);
|
||||
}
|
||||
|
||||
uint32_t ffStrbufLastIndexC(const FFstrbuf* strbuf, const char c)
|
||||
uint32_t ffStrbufPreviousIndexC(const FFstrbuf* strbuf, uint32_t start, char c)
|
||||
{
|
||||
if(start >= strbuf->length)
|
||||
return strbuf->length;
|
||||
|
||||
//We need to loop one higher than the actual index, because uint32_t is guranteed to be >= 0, so this statement would always be true
|
||||
for(uint32_t i = strbuf->length; i > 0; i--)
|
||||
for(uint32_t i = start + 1; i > 0; i--)
|
||||
{
|
||||
if(strbuf->chars[i - 1] == c)
|
||||
return i - 1;
|
||||
@@ -436,6 +440,11 @@ uint32_t ffStrbufLastIndexC(const FFstrbuf* strbuf, const char c)
|
||||
return strbuf->length;
|
||||
}
|
||||
|
||||
uint32_t ffStrbufLastIndexC(const FFstrbuf* strbuf, char c)
|
||||
{
|
||||
return ffStrbufPreviousIndexC(strbuf, strbuf->length - 1, c);
|
||||
}
|
||||
|
||||
void ffStrbufSubstrBefore(FFstrbuf* strbuf, uint32_t index)
|
||||
{
|
||||
if(strbuf->length <= index)
|
||||
|
||||
+5
-4
@@ -72,11 +72,12 @@ void ffStrbufRemoveStringsA(FFstrbuf* strbuf, uint32_t numStrings, const char* s
|
||||
void ffStrbufRemoveStringsV(FFstrbuf* strbuf, uint32_t numStrings, va_list arguments);
|
||||
void ffStrbufRemoveStrings(FFstrbuf* strbuf, uint32_t numStrings, ...);
|
||||
|
||||
uint32_t ffStrbufFirstIndexAfterC(const FFstrbuf* strbuf, uint32_t start, const char c);
|
||||
uint32_t ffStrbufFirstIndexC(const FFstrbuf* strbuf, const char c);
|
||||
uint32_t ffStrbufFirstIndexAfterS(const FFstrbuf* strbuf, uint32_t start, const char* str);
|
||||
uint32_t ffStrbufNextIndexC(const FFstrbuf* strbuf, uint32_t start, char c);
|
||||
uint32_t ffStrbufFirstIndexC(const FFstrbuf* strbuf, char c);
|
||||
uint32_t ffStrbufNextIndexS(const FFstrbuf* strbuf, uint32_t start, const char* str);
|
||||
uint32_t ffStrbufFirstIndexS(const FFstrbuf* strbuf, const char* str);
|
||||
uint32_t ffStrbufLastIndexC(const FFstrbuf* strbuf, const char c);
|
||||
uint32_t ffStrbufPreviousIndexC(const FFstrbuf* strbuf, uint32_t start, char c);
|
||||
uint32_t ffStrbufLastIndexC(const FFstrbuf* strbuf, char c);
|
||||
|
||||
void ffStrbufSubstrBefore(FFstrbuf* strbuf, uint32_t index);
|
||||
void ffStrbufSubstrBeforeFirstC(FFstrbuf* strbuf, const char c);
|
||||
|
||||
Reference in New Issue
Block a user